AlyssaK1
Programmer
- Jan 28, 2007
- 2
Hi everyone,
I'm using a validation javascript that is called onsubmit="return validate()".
This javascript is used to validate a login form. However now I have a servlet that runs off the same FORM - to check if the user exists etc.
<form name="login_form" method="post" action="Controller" onsubmit=" return validate()">
What would the correct way be to implement the scenario where the form only calls the servlet when validate javascript has returned true.
I have found it does enter the validate javascript function however it doesn't check if the fields are empty string, which it did without the servlet action. The servlet automatically returns a jsp page stating the login details don't exist in the database. Which obviously they don't.
Within the validation function valid = true automatically unless a field has an empty string then valid= false and the form should not be submitted.
If you have any ideas a response would be great.
Thanks, Alyssa
I'm using a validation javascript that is called onsubmit="return validate()".
This javascript is used to validate a login form. However now I have a servlet that runs off the same FORM - to check if the user exists etc.
<form name="login_form" method="post" action="Controller" onsubmit=" return validate()">
What would the correct way be to implement the scenario where the form only calls the servlet when validate javascript has returned true.
I have found it does enter the validate javascript function however it doesn't check if the fields are empty string, which it did without the servlet action. The servlet automatically returns a jsp page stating the login details don't exist in the database. Which obviously they don't.
Within the validation function valid = true automatically unless a field has an empty string then valid= false and the form should not be submitted.
If you have any ideas a response would be great.
Thanks, Alyssa