Click to See Complete Forum and Search --> : form validation script ..........


binmehar
04-19-2003, 01:33 AM
my javascript for validating the form is not working ........
i dont know why ....
please help me in this regard .......
here is the code .........



<html>
<head>



<title>Login</title>
<SCRIPT LANGUAGE = "JavaScript">

function validate(){

var reg = document.f1.reg_no.value
var pss = document.f1.pass.value

if (reg==")
{
alert('You have to provide your Registeration number.Please try atain');
event.returnValue=false;
}

if(pass=="){
alert('You have to provide the password.Please try again!');
event.returnValue=false;
)
}
</SCRIPT>






</head>
<body bgcolor="#C0C0C0">
<br>
<h3 align="center">Login Page</h3>
<p align="center"><i>Enter your reg. no and password to proceed further</i></p>
<br><br><br>
<form name="f1" action="ado_st.asp" method=post onSubmit="validate();" >
<P align="center" >
Reg. Number:
<input type="text" name="reg_no" size=10><br><br>
Password :<input type="password" name="pass" size=8><br><br>

<input type="Checkbox" name="save" value="OFF">Remember me
<br><br>
<input type="Submit" value="Login">
</p>
</form>
</body>
</html>

DrDaMour
04-19-2003, 01:50 AM
lots of little errors like " instead of "" a ) instead of a }, pss instead of pass. Anywho the following works

function validate(){

var reg = document.f1.reg_no.value
var pass = document.f1.pass.value

if (reg=="")
{
alert('You have to provide your Registeration number.Please try atain');
event.returnValue=false;
}

if(pass==""){
alert('You have to provide the password.Please try again!');
event.returnValue=false;
}

}
</SCRIPT>