Text control problem

Posted by chirivellaphaniraja-14771 under ASP.NET on 4/3/2012 | Points: 10 | Views : 635 | Status : [Member] | Replies : 4
Hi to all text control how to take only integer values not strings.......
please tell me
Thanks to u all




Responses

Posted by: Vuyiswamb on: 4/3/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
use JQuery

$(document).ready(function() {

$("#MyTextbox").keydown(function(event) {
// Allow: backspace, delete, tab and escape
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
else {
// Ensure that it is a number and stop the keypress
if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
}
});
});


Thank you for posting at Dotnetfunda
[Administrator]

chirivellaphaniraja-14771, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 4/3/2012 [Member] Starter | Points: 25

Up
0
Down
<asp:TextBox ID="txtorderid" runat="server" TabIndex="1"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtorderid" ErrorMessage="Numeric value only" ValidationExpression="^\d+$" ValidationGroup="a"></asp:RegularExpressionValidator>


ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

chirivellaphaniraja-14771, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 4/3/2012 [Member] Starter | Points: 25

Up
0
Down
i have used asp.net vallidation

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

chirivellaphaniraja-14771, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/3/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
is your problem resolved ?

Thank you for posting at Dotnetfunda
[Administrator]

chirivellaphaniraja-14771, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response