1.We can do validations in a form using java script.ie.If 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?
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. Bill
Create symphonies in seed and soil. For this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop