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.
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.
Description:- Take two
textboxes to accept two values from the user and check whether the values
entered in both the textboxes are numeric or not and put validation on it that
you can enter only numeric values. You can also
check the that the field marked as maximum should have greater value as
compared to the field marked as minimum if it is not so than put proper
validation for it.
Hint:
Key allowed in the textbox is 0-9, ‘.’.
<!--
Q-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>
Session 3 - 3rd Program
</title>
<script type="text/javascript">
function validate()
{
var min=myForm.txt_min.value;
var max=myForm.txt_max.value;
if(parseInt(min)==min && parseInt(max)==max)
{
if(parseInt(max)<parseInt(min))
{
alert("Sorry! Value of MAX must Be Greater");
}
else
{
alert(" Validated ");
}
}
else
{
alert("Both Must b Numeric Value");
}
}
</script>
</head>
<body>
<form name="myForm">
<table border="1" align="center" width="40%">
No comments:
Post a Comment