Thread View: comp.lang.javascript
2 messages
2 total messages
Started by Nada Omer
Fri, 08 Sep 2000 16:30
form validation using javascript
Author: Nada Omer
Date: Fri, 08 Sep 2000 16:30
Date: Fri, 08 Sep 2000 16:30
15 lines
1614 bytes
1614 bytes
I am doing a project where i am supposed to validate internet form from errors, and then dump these the form data into a file... i am using perl program to dump the values of each of the fields, but i am doing the field validation using javascript. At the moment, whenever, i use a script in an outside file, they work...but they never seem to work when i insert them into my file.... The file contains only two fields check out of 11 ... could anyone help me if i send the file via the net? cheers, nada Ibrahim MSc. Computing science.
Re: form validation using javascript
Author: Nada Omer
Date: Fri, 08 Sep 2000 16:45
Date: Fri, 08 Sep 2000 16:45
138 lines
4805 bytes
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">
<INPUT TYPE="Reset" VALUE="Reset"> </p>
<p> </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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads