asp.net keypress event
-
I want validation for text box in a text box enter only whole numbers(no decimal). The keypress event is not available in ASP.Net. How to get key press event? Can it be done using regular expression validator? Cheers Berba
-
I want validation for text box in a text box enter only whole numbers(no decimal). The keypress event is not available in ASP.Net. How to get key press event? Can it be done using regular expression validator? Cheers Berba
yes you can use regular expression ie) [^0-9].
-
I want validation for text box in a text box enter only whole numbers(no decimal). The keypress event is not available in ASP.Net. How to get key press event? Can it be done using regular expression validator? Cheers Berba
You can use a MaskedEdit textbox and set the mask to only accept numbers. No validation or event handling needed.
No comment
-
I want validation for text box in a text box enter only whole numbers(no decimal). The keypress event is not available in ASP.Net. How to get key press event? Can it be done using regular expression validator? Cheers Berba
Use a javascript/jquery function to achieve this: 1. HTML Mockup
Above, "onkeypress" is the client-side keypress event. For more accuracy, you could replace "onkeypress" with "onkeyup" which only fires when you let go of a "key" (on your keyboard). 2. Javascript/jQuery
function Validate( sender )
{
if( parseInt( sender.val() ) )
{
//proceed with the intended operation
}
else
{
alert( 'Sorry, only whole numbers are allowed in this input field. Please try again.' );
}
}