Inputing valid data

Results 1 to 4 of 4

Thread: Inputing valid data

  1. #1
    Marie Guest

    Default Inputing valid data

    if one of the fields is empty, a msgbox will prompt and remain at that page. <BR><BR>I can get it to work in this manner, but I want it to remains at that page with other present data in the fields.<BR><BR>How do I do that??<BR><BR>Example :<BR><BR>&#060;form name="form"><BR>&#060;input type=text value="lastname" name="lastname"><BR><BR>&#060;input type=text value="firstname" name="firstname"><BR><BR>&#060;input type=submit name="Submit" value="Submit"><BR>&#060;/form><BR>&#060;script language=vbscript><BR>sub Submit_onClick<BR>if window.document.form.lastname.value = "lastname" or window.document.form.firstname.value = "firstname" then<BR>alert("You must enter something in each field")<BR>exit sub<BR>else<BR>window.document.form.action = "validation.asp"<BR>window.document.form.metho d = "post"<BR>end if<BR>end sub<BR><BR><BR>

  2. #2
    Ian Stallings Guest

    Default RE: Inputing valid data

    This would be agreat time to use the Session<BR>object. you can store values like so:<BR>(i&#039ll explain in the comments)<BR><BR>&#060;%<BR>&#039first we get the data from the form and<BR>&#039assign it to a variable like so:<BR>name = request.form("name")<BR><BR>&#039we can then assign this to a session variable<BR>&#039like this:<BR>Session("name") = name<BR><BR>&#037;&#062;<BR><BR>ok, now that the data is in the session object we can<BR>place it in the fields like this:<BR><BR>&#060;input type="text" name="name" value="&#060;%=Session("name")&#037;&#062;"><BR><B R>So if the Session object has the data which they&#039ve entered<BR>it will be displayed in the text box.<BR><BR>I hope this helps. If you have<BR>further question or still need help<BR>just ask.<BR><BR><BR><BR><BR>

  3. #3
    Ian Stallings Guest

    Default another note

    Another note:<BR>If you want the user to remain at the same<BR>page you can submit the form to itself and <BR>use the session object to store the data.<BR><BR>If the data is present it will be displayed.<BR>If the user just came to the page, he will see the<BR>normal page.<BR><BR>After the data has been validated by the page<BR>you can use a redirect to send them on their way.<BR><BR>

  4. #4
    Marie Guest

    Default RE: Inputing valid data. To: Ian Stallings

    This my part of my program, I&#039ve not try session object b4. I&#039ve studied the help you gave me but I&#039m still not sure what and where to put in the instructions. Can you give me a hand on where to put the session object and I&#039ll still be able to remain at that page with other valid data after an empty field is found. <BR>Thanks <BR><BR> &#060;Form NAME="Form"><BR> &#060;TABLE><BR> &#060;TR> <BR> &#060;TD>Name:&#060;/TD><BR> &#060;TD>&#060;INPUT TYPE="text" NAME="SName" SIZE=30>&#060;/TD><BR> &#060;/TR><BR> &#060;TR><BR> &#060;TD>Student Number:&#060;/TD><BR> &#060;TD>&#060;INPUT TYPE="text" NAME="SNum" SIZE=30> &#060;/TD><BR> &#060;/TR><BR> &#060;INPUT NAME="Submit" TYPE=Submit Value="Submit">&#060;/TD><BR> &#060;/TABLE><BR> &#060;/FORM><BR><BR>&#060;Script Language ="Vbscript"><BR><BR>Sub Submit_OnClick<BR> If window.document.form.SName.value="" Then<BR> alert("Please Input Your Name.")<BR> Exit sub<BR> <BR> Elseif window.document.form.SNum.value="" Then<BR> alert("Please Input Your Student Number.")<BR> Exit sub<BR><BR> Else<BR> window.document.form.action="confirm.asp"<BR> window.document.form.method="post"<BR> End if<BR>End Sub <BR>&#060;/script>


Posting Permissions

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