Hello Friend today I want to tell you how to validate your form using javascript.
If You want to validate a text box that it may not be empty.
The HTML page would be something like this..
<html>
<head>
<title>Validate Demo</title>
<script type="text/javascript">
function validatefullname()
{
var fn=document.getElementbyId(fullname).valueOf;
var fne=document.getElementbyId(fullnameerr).valueOf;
if(fn.length==null)
{
fne.innerHtml="This field can not be empty";
}
else
{
fne.innerHtml="";
}
}
</script>
</head>
<body>
<form onsubmit="return formvalidate()">
<font>Your Name:</font>
<input type="text" name="name" value="" id="fullname" onblur="validate fullname()"/>
<label id="fullnameerr"></label>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Hope it will be helpfull to u pple...
Thank you.....
If You want to validate a text box that it may not be empty.
The HTML page would be something like this..
<html>
<head>
<title>Validate Demo</title>
<script type="text/javascript">
function validatefullname()
{
var fn=document.getElementbyId(fullname).valueOf;
var fne=document.getElementbyId(fullnameerr).valueOf;
if(fn.length==null)
{
fne.innerHtml="This field can not be empty";
}
else
{
fne.innerHtml="";
}
}
</script>
</head>
<body>
<form onsubmit="return formvalidate()">
<font>Your Name:</font>
<input type="text" name="name" value="" id="fullname" onblur="validate fullname()"/>
<label id="fullnameerr"></label>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Hope it will be helpfull to u pple...
Thank you.....