Hi,
I have a web application that allows users to submit feedback regarding the content currently on screen. I have a submit button on this form:
Click Here to Sumbit
I also have JS validation code in the onSubmit object of the form:
if (document.forms[0].Enquiry.value==“”){
alert(“You have not entered your enquiry/comment. Please do so to allow you to submit this query.”);
document.forms[0].Enquiry.focus();
return false();
};
If the Enquiry field is blank and the user clicks the Submit button then the onSubmit code is actioned and the alert appears, the focus switches to that field but then the form still submits and the URL in the $$Return field is launched.
Can anyone see where I am going wrong? I am kinda new to JS to any help/feedback is very much appreciated.
Cheers,
Kenny
Subject: Submit & Validate
in the onSubmit event enter:return doSubmit();
then code your submit function as follows:
function doSubmit() {
if (document.forms[0].Enquiry.value==“”){
alert("You have not entered your enquiry/comment. Please do so to allow you to submit this query.");
document.forms[0].Enquiry.focus();
return false();
} //no semi colon here!
return true;
}
Subject: RE: Submit & Validate
I know that these replies were posted a while ago but I have been off sick (nothing to do with javascript - honest!) and just wanted to say thanks for the advice.
I will try these solutions out.
Cheers
Kenny
Subject: submit() and onSubmit
If you use the submit() method, the onSubmit event is not execute. Put your validation js in the button before the submit() method OR use the onSubmit event and a @formula “submit” button with this formula:
@Command([FileSave]);
@Command([FileCloseWindow])