Hi guys I'm just starting with C#. I gotta do this for my project and have a hard time doing it.
I've gotta prevent people from entering numbers in my textbox of the program so they don't spoil it but I can't find anything that could do it. Anyone has any idea how? Tell my please thank you!!!
Techy WizardPosted Jul 24, 2008, 3:52 AM
You can use the Masked Textbox control. Set the mask property to '?'.
Ryan AlfordPosted Jul 24, 2008, 9:28 AM
Niradhip ChakrabortyPosted Jul 24, 2008, 4:52 AM
Call this javascript function on onkeypress of textbox.
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57)){
alert("Please enter digits");
return false;
}
else{
return true;
}
}
Sivangari VytheswaranPosted Jul 24, 2008, 3:52 AM
Hi
using Onkeypress event ,u can solve ur problem.
write the code in java script
1.First find the keyboard event code.
var key=e.keycode;
2.convert to this code to char and compare this char with ur string(if u give integers in this string ,u allow integer only.otherwise if u give a to z,u allow only char)
3.if condition satisfy, return true,otherwise return false.
4.above funtion called in textbox onkeypress event.