Prasad Bhagat

Prasad Bhagat

  • NA
  • 516
  • 235.4k

validate minmum and maximum salaries

Aug 8 2014 3:18 AM
Dear all,
 
i have two asp.net textboxes
txtminsal,txtmaxsal,
user when enter the lessthan min salary i want disply alert 
 
defualt.aspx
-------------------
<script type="text/javascript">
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
alert("enetr numbers");
return false;
}
return true;
}
function Button1_onclick() {
var a = document.getElementById('TextBox1').value;
var b = document.getElementById('TextBox2').value;

if (b < a) {

alert('Maxsal is should be greater than minsal');
return true;
}
else {

return false;

}
}
</script>
</head>
<body>
<form runat="server">
<asp:TextBox ID="TextBox1" runat="server" onkeypress="return isNumber(event)"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onkeypress="return isNumber(event)" OnTextChanged="Button1_onclick()"></asp:TextBox>
</form>
</body>
</html>
 this code is not working
pls help me asap

Answers (4)