I have one text box and button in asp.net like
<tr>
<td style="width: 100px">
<asp:Label ID="lbltime" runat="server" Text="Enter Time"></asp:Label>
</td>
<td style="width: 100px">
<asp:TextBox ID="Txttime" onkeypress="return isNumberKey(event)" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 100px" align="center">
<asp:Button ID="Btntime" runat="server" Text="Button" />
</td>
</tr>
Now I want to write JavaScript code to validate on my textbox which work when I click on button. Now I want to know how to call function of JavaScript in button and the function should do work like is button should send the text box value to the function and function should check the value to integer number only. And if not found should give the error message in the dialog box that "please enter value in integer only".
I'm trying the JavaScript like this:
function isNumberKey(textboxvalue)
{
evt=textboxvalue.text;
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
textboxvalue.text="Enter in Integer Only";
return false;
return true;
}