A simple OnSubmit Jscript problem...

Results 1 to 2 of 2

Thread: A simple OnSubmit Jscript problem...

  1. #1
    Nurice Guest

    Default A simple OnSubmit Jscript problem...

    Hi everyone!<BR>I have a form with two functions (And more coming) that all need to return true for the form to pass onto the next page This is the line I&#039m having problems with:<BR><BR>&#060;FORM ACTION="AddUser.asp" NAME="frmUser" METHOD="POST" onSubmit="return IsFormComplete(frmUser); VerifyData();"&#062;<BR><BR>Now, with this syntax, IsFormComplete will go through, and if it&#039s true it skips right past VerifyData. I&#039ve tried "AND" and also "&" but it returns with an error. I&#039ve thought of possibly starting up another function returning one true value if both are true, but I don&#039t know how to go about that- I&#039m a beginner JScripter. Any help is GREATLY appreciated!<BR>-Nurice

  2. #2
    Tom Levesque Guest

    Default RE: A simple OnSubmit Jscript problem...

    By adding the line onSubmit to an element:<BR><BR>&#060;form ... onSubmit="return somefunction();"&#062;<BR><BR>You&#039re saying "Do everything inside these quotes when the submit event happens." Your function, VerifyData() is *NOT* being ignored. It does run. However once IsFormComplete() has returned a true value, VerfifyData() cannot return some other value. return true; tells the browser to go ahead and submit, return false; tells the browser stop what it is doing.<BR><BR>If I am correct that VerifyDate() is just another thing you want to do when validating your form, there&#039s no reason you need to call it inside the onSubmit event. For example:<BR><BR>&#060;form name="whatever" method="POST"<BR>onsubmit="return IsFormComplete(frmUser);"&#062;<BR><BR>function IsFormComplete(...){<BR><BR>if(all_the_form_field_ values != "")<BR> return VerifyDate();<BR>}else{<BR> return false;<BR>}<BR>}<BR><BR>function VerifyDate(){<BR><BR>if(the_date_checks_out){<BR>r eturn true;<BR>}else{<BR>return false;<BR>}<BR>}<BR><BR>I have no idea what your subroutines look like but with this structure, the only way IsFormComplete() returns a TRUE value is if all the formed are compeleted AND the VerfifyDate() returns a true value as well (ie, the date is OK).<BR><BR>Tom Levesque<BR>tomlevesque@home.com<BR>http://www.city.windsor.on.ca/wpl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts