?
Solved

How do i make a validation page?

Posted on 2003-03-05
5
Medium Priority
?
186 Views
Last Modified: 2010-04-09
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....
0
Comment
Question by:space-cowboy
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:substand
ID: 8076115
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.

0
 

Author Comment

by:space-cowboy
ID: 8078382
hi,

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

thanks again.

Space-cowboy
0
 
LVL 10

Expert Comment

by:substand
ID: 8081965
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.
0
 

Author Comment

by:space-cowboy
ID: 8083931
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>
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 80 total points
ID: 8088075
Our experts are usually willing to help, BUT they don't do the homework. If people post the relevant part of the work they already did and if they have a very specific question about it most experts will jump in.

What we discourage is something like:
"Write a program that reads file xxx and does yyy with the number of that file"
and experts will post the complete code. That IS AGAINST 'academic honesty' as mentioned in the Member Agreement at http://www.experts-exchange.com/jsp/infoMemberAgreement.jsp.

** Mindphaser - Community Support Moderator **
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question