+ 1
Javascript form validation coding
2 Antworten
+ 3
be more specific and i'll try to help you
+ 2
I found your code, and i correct it. Next time post your code.
I suggest you to study harder HTML and JavaScript because your code is full of error.
<!DOCTYPE html>
<html><head>
<title>Javascript form</title>
<script type="text/javascript">
function sub ()
{
if(document.getElementById("t1").value==""){
alert("enter your name")
}
else if (document.getElementById("t2").value==""){
alert("please enter a password");
}
else if(document.getElementById("t2").value!=document.getElementById("t3").value){
alert("please enter correct password");
}
else if (document.getElementById("t4").value==""){
alert("please enter your address");
}
else{
alert("form has been submitted");
}
}
</script>
</head>
<body align="center" bgcolor="red">
<h1>.......javascript form.......</h1>
<form>
<p>
<label>user name*</label><input type="text" id="t1"><br /><br />
<label>password*</label><input type="text" id="t2"/><br /><br />
<label>confirm password*</label><input type="text" id="t3"/> <br /><br />
<label>Address*</label><textarea rows="2" cols="25" id="t4"></textarea> <br /><br />
<input type="button" value="submit" onclick="sub()"/>
<input type ="reset" value="clear all"/> </p>
</form>
</body>
</html>