ASP form error checking...please help!

Results 1 to 3 of 3

Thread: ASP form error checking...please help!

  1. #1
    Join Date
    Dec 1969

    Default ASP form error checking...please help!

    Hello....Jeremy with BYP here again.<BR><BR>Here&#039s what I want to do. I have a simple form with checkboxes, an email field, and a zip code field. I want to require that the user put SOMETHING in the doesn&#039t matter what it is at the moment. I just need something simple. Any advice you guys can give would be appreciated<BR><BR>- Jeremy

  2. #2
    Karl Guest

    Default RE: ASP form error checking...please help!

    There are zillions of site which deal with form validation...a quick run-down.<BR><BR>You have two choices, client-side or server-side validation. The latter let&#039s you use VBscript (you can do client-side validation in VBscript but it won&#039t work for netscape browsers). Server-side validation is also less ressource friendly..and it requires the user to actually submit the page, go to another page, collect the information and check it. Which means if it&#039s wrong you have to redisplay all the information.<BR><BR>Client-side on the other hand is better, except it requires the client to be able to run the validation..this means using JavaScript (there might be reasons why you wouldn&#039t want to use client-side..but I don&#039t know any).<BR><BR>I&#039ve included a bit of code to get you started...I recommend you fully test this using both netscape and MSIE since they handle javascript differently (the code I included should be fully functional in both browsers thought)<BR><BR>your form field will have to have a name, and an onSubmit event handler..such as:<BR>&#060;form method="post" action="blah2.asp onsubmit="return Validate(var1)" name="formname"&#062;<BR><BR>Validate() is the name of the function (which I&#039ll quickly explain latter) is set up to handle 2 variables. You pass values to it from the form with document.formname.fieldname.value<BR><BR>Ex.Say you have a field like: <BR>&#060;input name="username" type="text"&#062;<BR>You&#039d use document.formname.username.value<BR><BR>Your Validate() function would then look like:<BR><BR>&#060;SCRIPT LANGUAGE="javascript"&#062;<BR>&#060;!--<BR> function Validate(userName) {<BR> if(userName == ""){<BR> alert("Must have a username");<BR> return false;<BR> }<BR> }<BR>--&#062;<BR>&#060;/SCRIPT&#062; <BR><BR>I hope this helps!<BR><BR>--<BR>Karl<BR><BR>Note that if the data doesn&#039t validate properly (it&#039s blank) you MUST return false; to stop your form from submitting. Also note that Javascript IS cAsE sEnSiTiVe.

  3. #3
    Karl Guest

    Default RE: ASP form error checking...please help!

    bah..that Validate(var1) function is set up to handle 1 variable..not 2..sorry.<BR><BR>Karl

Posting Permissions

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