For any javascript validation I have to add java script event
in text box on page load event in asp.net page ,Here I am adding OnKeyPress
event on textbox as I am restricting all other key apart from numeric as in
below code.
|
txtAmount.Attributes.Add("onKeypress", "
NumericValidation (event);");
|
Now Below is the HTML code where I will call Numeric
Validation function on keypress of Text Box.
|
<asp:TextBox ID="TxtEdpFeb"
runat="Server"
Text=”” onKeypress="NumericValidation(event)"
/>
|
Now below is the javascript function which will
call on key press event of Text Box.
|
function NumericValidation(event) {
if
(event.keyCode < 44 || event.keyCode > 57 || event.keyCode == 44 ||
event.keyCode == 45 || event.keyCode == 46 || event.keyCode == 47)
event.returnValue = false;
}
|
0 comments:
Post a Comment