For simple Javascript Validation !
<html>
<head>
<title>Simple validation</title>
<script type="text/javascript">
function val()
{
var name= document.getElementById("n").value;
// alert('name');
if(name=='')
{
alert('please fill the blank');
}
else
{
alert(name);
}
}
</script>
</head>
<body>
<form method="post">
<table align="center" border="1" cellspacing="1" cellpadding="4">
<tr>
<td>Name</td>
<td><input type="text" id="n" name="n"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" id="submit" name="submit" value="Submit" onclick="return val()"></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>Simple validation</title>
<script type="text/javascript">
function val()
{
var name= document.getElementById("n").value;
// alert('name');
if(name=='')
{
alert('please fill the blank');
}
else
{
alert(name);
}
}
</script>
</head>
<body>
<form method="post">
<table align="center" border="1" cellspacing="1" cellpadding="4">
<tr>
<td>Name</td>
<td><input type="text" id="n" name="n"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" id="submit" name="submit" value="Submit" onclick="return val()"></td>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment