🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.javascript
Article #59

Re: form validation using javascript

#59
From: Nada Omer
Date: Fri, 08 Sep 2000 16:45
138 lines
4805 bytes
sorry, but i decided that it is quicker to show you the file from the
start...

enclosed you will find my file...where it's URL is 
www.cs.ncl.ac.uk/people/n.o.a.ibrahim/home.informal/user/testjava.htm

the source code is 
<html> 
 
<head> 
<meta http-equiv="Content-Type" 
content="text/html; charset=iso-8859-1"> 
<meta name="GENERATOR" content="Microsoft FrontPage 4.0"> 
<title></title> 

<script language="javascript">


                <!-- Hide script from older browsers
                
        function validate()
        {
          var digits = "0123456789"
          var temp
          
          if (document.testform.Password.value == "") 
          {
            alert("You must enter a password")
            testform.Password.focus()
            return false
          }
          if (document.testform.Confirm_Password.value == "") 
          {
            alert("You must confirm your password")
            testform.Confirm_Password.focus()
            return false
          }
          if (document.testform.Password.value
!=document.testform.Confirm_Password.value) 
          {                                
            alert("Entered passwords did not match")     
            return false  
          }

         
if(document.testform.Password.value.length!=document.testform.Confirm_Password.value.length) 
          {                                   
            alert("Entered passwords did not
match")                           
            return false
          }    
     
          for (var i=0;i i<document.testform.Tel_no.value.length;i++)
                {
                 temp=document.testform.Tel_no.value.substring(i,i+1)
                if (digits.indexOf(temp)==-1)
                {
                  alert("Invalid Tel no.!")
                 return false
                 }
                }
                return true
}

                   // End hiding script -->     

</SCRIPT>   

 </head> 
 
<body >
<form name="testform" onSubmit ="return validate()" method="POST"
action=http://www.cs.ncl.ac.uk/people/n.o.a.ibrahim/cgi-bin/12.cgi> 

<table border="0"
width="100%">  <tr>  <td><center> 
<a href="http://www.bcs.org.uk/"> 
<img src="http://www.bcs.org.uk/graphics/webcrest.gif" width="83" 
height="122"> 
</a></center></td> 
</tr> 
 
<p>Surname<input type="text" size="17" maxlength=12 
name="Surname"></p> 

<p>Other_Names<input type="text" size="17" maxlength=12 
name="Other_Names"></p> 

 </td> 
      <td width="652" colspan="2" height="25"><div align="left"><p><font
size="3"><input type="text" name="Email" size="20" maxlength="200"
tabindex="16" value=""></font> 
        </div><strong></font></strong> 
 </td> 
    </tr> 
</table>

<p>Tel no. <INPUT TYPE="text" size="20" maxlength=15 NAME="Tel_no"></p>
 
<p>Login name <input type="text" size="15" maxlength=10
name="Login_name"></p>


<p>Password<input type=password size="15" maxlength=90 name="Password"
</p>

<p>Confirm Password <input type=password size="15" maxlength=90 
name="Confirm_Password" </p>


<p>Do you wish to be added to the branch mailing list: Yes <input
type="radio" checked
name="Do_you_wish_to_be_added_to_the_branch_mailing_list" value="Yes">
No <input
type="radio" name="Do_you_wish_to_be_added_to_the_branch_mailing_list"
value="No"></p>


<p><INPUT TYPE="Submit" VALUE="Submit"> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<INPUT TYPE="Reset" VALUE="Reset"> </p> 
 
<p>&nbsp;</p> 


<hr>
<address><a href="mailto:N.O.A.Ibrahim@newcastle.ac.uk">Nada Ibrahim</a> 
</address><p> 
<i>Last modified:Sunday, September, 8th 2000</i><p> 

</form> 

</body>
</html>

cheers,

nada
Technical Details
Message-ID: <39B917C7.F4D9847C@ncl.ac.uk>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!newsfeed.direct.ca!look.ca!netnews.com!news.maxwell.syr.edu!newsfeed.esat.net!news.heanet.ie!server5.netnews.ja.net!news.ncl.ac.uk!not-for-mail
References: <39B91428.88A1DAC7@ncl.ac.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10731d,f89e54a3cc9eac89
X-Google-Attributes: gid10731d,public
X-Google-Thread: fb3cb,f89e54a3cc9eac89
X-Google-Attributes: gidfb3cb,public
X-Google-ArrivalTime: 2000-09-08 10:00:32 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!newsfeed.direct.ca!look.ca!netnews.com!news.maxwell.syr.edu!newsfeed.esat.net!news.heanet.ie!server5.netnews.ja.net!news.ncl.ac.uk!not-for-mail
From: Nada Omer <n.o.a.ibrahim@ncl.ac.uk>
Newsgroups: comp.lang.javascript,borland.public.intrabuilder.javascript
Subject: Re: form validation using javascript
Date: Fri, 08 Sep 2000 17:45:59 +0100
Organization: University of Newcastle upon Tyne
Lines: 138
Message-ID: <39B917C7.F4D9847C@ncl.ac.uk>
References: <39B91428.88A1DAC7@ncl.ac.uk>
NNTP-Posting-Host: twyford.ncl.ac.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16 i586)
X-Accept-Language: en