B
bnp
Hi All,
I am quite new the JavaScript. Basically I am a C++ programmer, but
now I am working on JavaScript since last 5 days.
I have a problem regarding the form validation.
I have created a script that validates the form fields. the validation
procedure is called ONCLICK event of the submit button.
Follwowing is the structure of the validation procedure.
------------------------------------------
// declaration for Submit Button
<input type="submit" name="btnSubmit" onclick="validate()">
function validate()
{
var bValidated = true;
// check form fields.
// If not valid then bValidated = false
if (bValidated)
{
form.action = "BackEnd..php"
form.method = "POST"
form.submit();
}
else
{
return false;
}
-----------------------------------------
Everythingg goews OK, if all fields are valid. But if any field
contains Invalid data, the validate returns false, and all the fields
in the form are reset, and user has to fill all the fields again.
I want that, if validation fails, the fields which are valid should
retain their values. How can I accomplish this?
Which event is called, if validation procedure fails? IS it "onreset"?
Help me soon.
Thanks & Regards,
Bhavik
I am quite new the JavaScript. Basically I am a C++ programmer, but
now I am working on JavaScript since last 5 days.
I have a problem regarding the form validation.
I have created a script that validates the form fields. the validation
procedure is called ONCLICK event of the submit button.
Follwowing is the structure of the validation procedure.
------------------------------------------
// declaration for Submit Button
<input type="submit" name="btnSubmit" onclick="validate()">
function validate()
{
var bValidated = true;
// check form fields.
// If not valid then bValidated = false
if (bValidated)
{
form.action = "BackEnd..php"
form.method = "POST"
form.submit();
}
else
{
return false;
}
-----------------------------------------
Everythingg goews OK, if all fields are valid. But if any field
contains Invalid data, the validate returns false, and all the fields
in the form are reset, and user has to fill all the fields again.
I want that, if validation fails, the fields which are valid should
retain their values. How can I accomplish this?
Which event is called, if validation procedure fails? IS it "onreset"?
Help me soon.
Thanks & Regards,
Bhavik