Hello
I have code of required field validation by using java script but what is the problem inside it?
<!--Required Validation by java script-->
<html>
<head>
<script type="text/javascript" src="Script.js">
function checkname() {
var val1=document.getElementById("name").value
if (val1 == "") {
document.getElementById("res1").innerHTML = "Please Fill this field";
}
else{
document.getElementById("res1").innerHTML = "";
}
}
function checkemail() {
var val2=document.getElementById("email").value
if (val2 == "") {
document.getElementById("res2").innerHTML = "Please Fill this field";
}
else{
document.getElementById("res2").innerHTML = "";
}
}
function checkpass() {
var val3=document.getElementById("pass").value
if (val3 == "") {
document.getElementById("res3").innerHTML = "Please Fill this field";
}
else{
document.getElementById("res3").innerHTML = "";
}
}
</script>
</head>
<body>
<form>
<table>
<tr>
<td>Name</td>
<td><input type="text" id="name" onchange="checkname()"/></td>
<td id="res1"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" id="email" onchange="checkemail()"/></td>
<td id="res2"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" id="pass" onchange="checkpass()"/></td><td id="res3"></td>
</tr>
<tr>
<td></td>
<td><input type="button" id=" value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
Actually I want to know that why onchange event not working properly can any one explain me
Thank You :)