onSubmit Form Validation

Results 1 to 4 of 4

Thread: onSubmit Form Validation

  1. #1
    Kenyon Guest

    Default onSubmit Form Validation

    I have a form that, when submitted, calls a sub procedure. The sub procedure does some error handling and then either returns a message box with an error or continues submitting the form.<BR><BR>The problem I&#039m having is that the sub procedure is working except it submits the form everytime, even when the error message is displayed. What am I doing wrong?<BR><BR>Here is my form tag:<BR>&#060;FORM language=vbscript name="GoToSetup" method="Get" action="start_handler.asp" onSubmit="call ValidateExist()"&#062;<BR><BR>Here is my submit tag:<BR>&#060;INPUT LANGUAGE="VBScript" type=submit name=btnEnter value="Return to Assessment"&#062;<BR><BR>And here is my sub procedure:<BR>Sub ValidateExist()<BR> <BR> If GoToSetup.lstAssessment.value = "" then<BR> msgbox "You must select an existing assessment from the list.",,"Error - Assessment Selection"<BR> GoToSetup.lstAssessment.focus()<BR> Else<BR> GoToSetup.submit<BR> End if<BR> <BR>End Sub<BR><BR>The problem is that when the form object lstAssessment is blank, the message box is displayed, but the form is also submitted.

  2. #2
    KPW Guest

    Default RE: onSubmit Form Validation

    You must turn this into a function that returns either true or false. Then, your onSubmit value for your form tag should look like "return ValidateExist()"<BR><BR>(This is how JavaScript works, at least; I&#039ve never actually done form validation in VBScript.)

  3. #3
    Kenyon Guest

    Default RE: onSubmit Form Validation

    I thought this might be the solution, but how do you do this in VBScript?

  4. #4
    Join Date
    Dec 1969

    Default RE: onSubmit Form Validation

    hey just try this.....<BR><BR>in error loop after u show the message box type submit=false <BR>& in the other loop type submit=true, this should work....try this & let me know<BR><BR>If GoToSetup.lstAssessment.value = "" then<BR>msgbox "You must select an existing assessment from the list.",,"Error - Assessment Selection"<BR>GoToSetup.lstAssessment.focus()<BR>s ubmit=false<BR>Else<BR>GoToSetup.submit<BR>submit= true<BR>End if<BR><BR>

Posting Permissions

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