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....
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....
ASKER
hi,
thanks for that will be trying it asap. i am using HTML and Java if thats any use?
thanks again.
Space-cowboy
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.
ASKER
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-Langua ge" 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:/Documen ts and Settings/Paul/My Documents/My Webs/myweb/_private/form_r esults.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 &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp;
<input type="text" name="T1" size="20"></p>
<p>Last name &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp;
<input type="text" name="T1" size="20"></p>
<p>Address &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp;
<input type="text" name="T1" size="20"></p>
<p>Address 2 *(optional) &nb sp; & nbsp;  ; &nb sp; & nbsp;  ;
<input type="text" name="T1" size="20"></p>
<p>City & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ;
<input type="text" name="T1" size="20"></p>
<p>County   ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;
<input type="text" name="T1" size="20"></p>
<p>Post code &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp;
<input type="text" name="T1" size="20"></p>
<p>Telephone No *(optional) &nb sp; & nbsp;  ;
<input type="text" name="T1" size="20"></p>
<p>Email address. &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p;
<input type="text" name="T1" size="20"></p>
<p>
========================== ========== ========== ========== ========== ========== =======</p >
<p>Please select username and password.</p>
<p>Username &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ;
<input type="text" name="T1" size="20"></p>
<p>Password &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp; & nbsp;  ; &nb sp;
<input type="password" name="T1" size="20"></p>
<p>Confirm password &nbs p; &n bsp; &nbs p; &n bsp; &nbs p;
<input type="password" name="T1" size="20"></p>
<p> </p>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="file:///C:/Documen ts and Settings/My Documents/My Webs/myweb/_private/form_r esults.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>
cheers.
<html>
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.
<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:/Documen
<!--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 &nbs
<input type="text" name="T1" size="20"></p>
<p>Last name &nbs
<input type="text" name="T1" size="20"></p>
<p>Address &nbs
<input type="text" name="T1" size="20"></p>
<p>Address 2 *(optional) &nb
<input type="text" name="T1" size="20"></p>
<p>City &
<input type="text" name="T1" size="20"></p>
<p>County  
<input type="text" name="T1" size="20"></p>
<p>Post code &nbs
<input type="text" name="T1" size="20"></p>
<p>Telephone No *(optional) &nb
<input type="text" name="T1" size="20"></p>
<p>Email address.
<input type="text" name="T1" size="20"></p>
<p>
==========================
<p>Please select username and password.</p>
<p>Username &nb
<input type="text" name="T1" size="20"></p>
<p>Password &nb
<input type="password" name="T1" size="20"></p>
<p>Confirm password
<input type="password" name="T1" size="20"></p>
<p> </p>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="file:///C:/Documen
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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))!=
alert("Invalid E-mail ID")
return false
}
if (str.substring(lat-1,lat)=
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(dot,(lat+2))=
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
if ((emailID.value==null)||(e
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (echeck(emailID.value)==fa
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.