asp & javascript - validating forms

Results 1 to 5 of 5

Thread: asp & javascript - validating forms

  1. #1
    jeffwilson Guest

    Default asp & javascript - validating forms

    I&#039m trying to validate my forms on the client side before making a POST to an asp page. Such as:<BR>&#060;form name="blahblah" action="process.asp" method="post" onsubmit="validate();"&#062;<BR><BR>The validation works fine and I&#039m catching the errors, however, when an error occurs I "return false;" from my script but it submits the form anyway. I&#039ve also tried to use a regular button, use the onclick() method to call the validate() routine and use the submit() method of the form from within the javascript but I get an error saying the object doesn&#039t support this method - when I know it does. <BR><BR>Can anybody help me here? Thanks a bunch!

  2. #2
    Slim Shady Guest

    Default RE: asp & javascript - validating forms

    onsubmit="return validate();"<BR><BR>then put a return false in the script<BR><BR>

  3. #3
    the real slim shady Guest

    Default RE: asp & javascript - validating forms

    I&#039ve had this problem too !<BR><BR>I hide the submit button buy setting it&#039s height and width to 0px. I display an ordinary button for the user. That button does the validation. If validation is successful, then I issue the command:;.<BR><BR>This technique works but it&#039s messy. If the other slim shady&#039s technique works then use that one. It&#039s much cleaner. I guess maybe I&#039m not the real slim shady afterall.

  4. #4
    MnM Guest

    Default RE: asp & javascript - validating forms

    Hi,<BR>Just going along with the theme!<BR>I think your problem is you are using an html submit button:<BR>&#060;INPUT TYPE="Submit" VALUE="Submit" NAME="cmdSubmit"&#062;<BR>and trying to validate the form using VBScript. I will go along on this supposition, if this is wrong, pleez excuse me. The problem doing this is the form will still post either way. You have two choices; use JavaScript to validate using the real slim shadys return idea; or change the button to a normal button:<BR>&#060;INPUT TYPE="Button" VALUE="Submit" NAME="cmdSubmit"&#062;<BR>then in the VBScript:<BR>&#060;SCRIPT LANGUAGE="VBScript"&#062;<BR>sub cmdSubmit_OnClick()<BR>&#039do validation<BR>if validData then<BR>formName.submit<BR>else<BR>msgbox("Invalid Data",vbOK+vbCritical,"Real SLim Shadee") <BR>end sub<BR>&#060;/SCRIPT&#062;<BR>Unfortunately, this will not work on a mac because it cant support client-side VBScript, so ure best bet is to use JavaScript.<BR>Hope it helps,<BR>MnM

  5. #5
    jeffwilson Guest

    Default RE: asp & javascript - validating forms

    funny that i&#039m listening to eminem right now, then i come here and have responses from slim shady, the real slim shady and Mnm - go figure!

Posting Permissions

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