This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

java script

Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.We can do validations in a form using java we keep one text field blank we give an alert message.After clicking "ok"
of alert message control goes to the next jsp.I want to keep control in the same page(provided any blank field is there).Can you write how this problem to be solved?
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this question is more appropriate to the HTML & Javascript forum so I am moving it there.
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, when you click a button, it will not go to the next page unless you tell it to, so be default, it will stay on the current page. That is unless you use a submit button.
I have done form validation in two different forms. One is where I use a submit button and have a function that gets called onSubmit in the form tag. This works well, you just have to return false if the form has error and you don't want it to submit. If you have it return true, it will submit. So basically, you run down all of the validation you need, if there is an error, return false and at the very end of the function return true. Because if it hits one of the return false, it takes you out of the function so the return true never gets executed. If it gets to return true, then all the validation must have passed, so you want it to submit.
The second form is similar, except you have a button that has an onClick event that checks the form. If there is an error you direct them to the error with an alert box (same as above) and then do something like field.focus() to put them on the field with the error. If there are no errors, then at the end of the function have a form.submit() call that submits the form for you.
But to answer your question, the page won't submit unless you tell it to, so it will stay right where you want.
Create symphonies in seed and soil. For this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic