Link to home
Start Free TrialLog in
Avatar of space-cowboy
space-cowboy

asked on

How do i make a validation page?

hi,

i was wondering if anyone can help me, i am currently doing a project on validation pages, but being generally new to internet programming, i havent a clue on how i would achive this. here is the outline for the project.

You are asked to produce a registration page for an English web site. The page should contain a form asking for the following information:
     Title (Drop down box)
     First name
     Last name
     Address Line 1
     Address Line 2 (optional to fill in)
     City
     County
     Postcode
     Telephone Number (optional to fill in)
     E-Mail address

In addition the following will be required:
     User name
     Password
     Password confirmation

The page should validate the fields and display an error message for any empty compulsory fields and boxes with the incorrect format. E.g. invalid e-mail address, numbers in the name field, etc.. The two attempts to enter a password must also agree although any restrictions on password.

Only if the form validates should a pop-up window appear containing the registration information (although obviously not the password).

again, i am really lost on this and if anyone could help me i would greatly apprieciate it. cheers.

SPACE-COWBOY....
Avatar of substand
substand

you'll need to let us know which languages you are using to validate.

if it's javascript, you'll need to add the method to your form:

<form action="actionpage.htm" onsubmit="return validate();" id=formname>

then in your head add the following code:

<script language = "Javascript">

function echeck(str) {

          var at="@"
          var dot="."
          var lat=str.indexOf(at)
          var lstr=str.length
          var ldot=str.indexOf(dot)
          if (str.indexOf(at)==-1){
             alert("Invalid E-mail ID")
             return false
          }

          if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
             alert("Invalid E-mail ID")
             return false
          }

          if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
              alert("Invalid E-mail ID")
              return false
          }

           if (str.indexOf(at,(lat+1))!=-1){
              alert("Invalid E-mail ID")
              return false
           }

           if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
              alert("Invalid E-mail ID")
              return false
           }

           if (str.indexOf(dot,(lat+2))==-1){
              alert("Invalid E-mail ID")
              return false
           }
         
           if (str.indexOf(" ")!=-1){
              alert("Invalid E-mail ID")
              return false
           }

            return true                        
     }

function validate(){
     var emailID=document.frmSample.txtEmail
     
     if ((emailID.value==null)||(emailID.value=="")){
          alert("Please Enter your Email ID")
          emailID.focus()
          return false
     }
     if (echeck(emailID.value)==false){
          emailID.value=""
          emailID.focus()
          return false
     }
     return true
 }
</script>

all the other validations are similar and can use snippets from that code.  that code is from http://www.smartwebby.com/DHTML/email_validation.asp

... you can check more there if you need it.

Avatar of space-cowboy

ASKER

hi,

thanks for that will be trying it asap. i am using HTML and Java if thats any use?

thanks again.

Space-cowboy
java or javascript?  it sounds like what you need is javascript. if so, send the html for your form and i'll do a quick auto-validate that you'll need to edit a bit, like the var names and stuff.
k, here is the html, been using frontpage, dont know if thats any good, its just what i have been told to use.

cheers.

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<meta name="Microsoft Theme" content="network 011, default">
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--">
  <!--webbot bot="SaveResults" U-File="file:///C:/Documents and Settings/Paul/My Documents/My Webs/myweb/_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><p>
  <!--webbot bot="Validation" S-Display-Name="Title" B-Value-Required="TRUE" --><select size="1" name="D1" multiple>
  <option>MR</option>
  <option>Miss</option>
  <option>Mrs</option>
  <option>Ms</option>
  </select></p>
</form>
<p>First Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Last name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Address 2 *(optional)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>City&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>County&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Post code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Telephone No *(optional)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Email address.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>
===================================================================================</p>
<p>Please select username and password.</p>
<p>Username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="T1" size="20"></p>
<p>Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="password" name="T1" size="20"></p>
<p>Confirm password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="password" name="T1" size="20"></p>
<p>&nbsp;</p>
<form method="POST" action="--WEBBOT-SELF--">
  <!--webbot bot="SaveResults" U-File="file:///C:/Documents and Settings/My Documents/My Webs/myweb/_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><p>
  <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
ASKER CERTIFIED SOLUTION
Avatar of Mindphaser
Mindphaser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial