Search This Blog

Thursday, 6 September 2012

Practical-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.


Filename-js3.html

<html>
<head>
<script language="javascript">
function checkval(myno)
{
if(isNaN(myno.value))
{
alert("plz enter number");

myno.focus();
}
}
function val(no1,no2)
{
if(no1.value> no2.value)
{
alert("plz enter no2 is gretter then no1");
no2.focus();
}
}
function add()
{ frm.result.value=parseInt(frm.minno.value)+parseInt(frm.maxno.value);
}
</script>
</head>
<body>
<form name="frm">
Enter min no=<input type="text" name="minno" onBlur="checkval(this.form.minno)"/>
<br>
Enter max no= <input type="text" name="maxno" onBlur="checkval(this.form.maxno),add(),val(this.form.minno,this.form.maxno)" />

<br>
addtion of two no
<input type="result" name="result" readonly="readonly" onBlur=""/>
</form>
</body>
</html>

Output
Enter min no=
Enter max no=
addtion of two no


No comments:

Post a Comment