postheadericon 3. Create a Form in HTML with two fields, minimum and maximum, write JavaScript to validate that only numeric value is entered in both, and the value entered in minimum is less than the value entered in maximum.



<html>
<head>
<title>EX-3: WTAD : www.bipinrupadiya.com</title>
<script language="javascript">
function isValid()
{
m=parseInt(document.myform.txtMax.value);
n=parseInt(document.myform.txtMin.value);
if(m<n)
{
document.getElementById("error").innerHTML="Maximum Number can not be less then Minimum Number ";
}
else
{
document.getElementById("error").innerHTML="*";
}
}
function isNum(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if(! (charCode >= 48 &&charCode <= 57))
{
return false;
}
return true;
}
</script>
</head>
<body>
<form name="myform">
<br>Maximum No.:<input type="text" name="txtMax" onkeyup='isValid()' onkeypress='return isNum(event)'>
<br>Minimum No.:<input type="text" name="txtMin" onkeyup='isValid()' onkeypress='return isNum(event)'>
<div id="error"></div>
</form>
</body>
</html>

0 comments:

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.