Hi,
dear all,
i have ready use control telerik RadTextBox and RadNumericTextBox ,
I want accept Only Number Using Javascript,
I have Followed thread
http://www.telerik.com/community/forums/aspnet-ajax/input/i-need-a-text-box-that-only-accepts-numbers.aspx
and
http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/radtextbox-need-to-be-restricted-only-for-integers.aspx
I am following that trick,
In IE is Fine and Work, But in FireFox is Not Work..
some body can help....
dear all,
i have ready use control telerik RadTextBox and RadNumericTextBox ,
I want accept Only Number Using Javascript,
I have Followed thread
http://www.telerik.com/community/forums/aspnet-ajax/input/i-need-a-text-box-that-only-accepts-numbers.aspx
and
http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/radtextbox-need-to-be-restricted-only-for-integers.aspx
I am following that trick,
In IE is Fine and Work, But in FireFox is Not Work..
some body can help....
7 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 22 Jul 2013, 05:43 AM
Hi
Please have a look into the following code I tried which works fine at my end.
ASPX:
JavaScript:
Thanks,
Shinu.
Please have a look into the following code I tried which works fine at my end.
ASPX:
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
ClientEvents-OnKeyPress
=
"OnKeyPress"
>
</
telerik:RadTextBox
>
JavaScript:
<script type=
"text/javascript"
>
function
onkeypress(sender, args) {
var
keycode = args.get_keyCode()
if
(!(keycode >= 48 && keycode <= 57) || (keycode >= 96 && keycode <= 105)) {
args.set_cancel(
true
);
}
}
</script>
Thanks,
Shinu.
0

Misbakhul
Top achievements
Rank 1
answered on 22 Jul 2013, 11:38 AM
trims shinu for your answer...
I try your solution, but still does not work in firefox....
I am using FireFox update 23.0...
trims a lot..
I try your solution, but still does not work in firefox....
I am using FireFox update 23.0...
trims a lot..
0
Hi Misbakhul,
Thank you for contacting us.
Since I was able to use two of the approaches from the threads you have mentioned that are working fine in IE, Chrome, Firefox 22.0 (last official version) and Firefox 23.0 beta, I will kindly ask you to provide a code snippet with how you are trying to implement this in your project.
I am attaching a simple project, demonstrating how you can achieve this behavior of the RadTextBox.
Please try it and see if it works on your side.
Regards,
Konstantin Dikov
Telerik
Thank you for contacting us.
Since I was able to use two of the approaches from the threads you have mentioned that are working fine in IE, Chrome, Firefox 22.0 (last official version) and Firefox 23.0 beta, I will kindly ask you to provide a code snippet with how you are trying to implement this in your project.
I am attaching a simple project, demonstrating how you can achieve this behavior of the RadTextBox.
Please try it and see if it works on your side.
Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

Misbakhul
Top achievements
Rank 1
answered on 27 Jul 2013, 09:27 PM
hi Konstantin Dikov,
trims to reply
I implemented the code that I get from the samples that I got from the forum as well ..
and any code samples you've ever applied in my project.
problems is the same, before its possible sorry I forgot one thing,
the piece of code you gave and I've never applied before its too successful, could mean only numbers.
but it can not delete the number from RadTextBox or RadNumericTextBox when running applications in Firefox, even before his version could not ..can not Backspace...
for this to be a problem in my client when the UAT process. because the application will be publicly hosting ..
trims a lot.....
trims to reply
I implemented the code that I get from the samples that I got from the forum as well ..
and any code samples you've ever applied in my project.
problems is the same, before its possible sorry I forgot one thing,
the piece of code you gave and I've never applied before its too successful, could mean only numbers.
but it can not delete the number from RadTextBox or RadNumericTextBox when running applications in Firefox, even before his version could not ..can not Backspace...
for this to be a problem in my client when the UAT process. because the application will be publicly hosting ..
trims a lot.....
0

Shinu
Top achievements
Rank 2
answered on 29 Jul 2013, 06:03 AM
Hi Misbakhul,
I have added few lines to the Admin's code and You can try the following updated JavaScript in order to get the BackSpace key working in Firefox.
JavaScript:
JavaScript:
Thanks,
Shinu.
I have added few lines to the Admin's code and You can try the following updated JavaScript in order to get the BackSpace key working in Firefox.
JavaScript:
function
OnKeyPress(sender, args) {
var
keycode = args.get_keyCode()
if
(keycode == 8) {
//Checking if the key pressed is BackSpace key, then do not cancel the event.
return
;
}
else
if
(!(keycode >= 48 && keycode <= 57) || (keycode >= 96 && keycode <= 105)) {
args.set_cancel(
true
);
}
}
JavaScript:
function
keyPress(sender, args) {
if
(args.get_keyCode() == 8) {
return
;
}
else
{
var
text = sender.get_value() + args.get_keyCharacter();
if
(!text.match(
'^[0-9]+$'
))
args.set_cancel(
true
);
}
}
Thanks,
Shinu.
0
Hi Misbakhul,
In addition to Shinu's reply I want to add that RadNumericTextBox have that functionality out of the box and if there is no particular reason that you need to use RadTextBox, please consider using RadNumericTextBox instead.
And just one more thing to add: If you experience some issues with RadNumericTextBox under Firefox 23 only, have in mind that this is still a beta version and not an official one (even though we have tested RadNumericTextBox under the latest Firefox Beta and no issues were present).
Regards,
Konstantin Dikov
Telerik
In addition to Shinu's reply I want to add that RadNumericTextBox have that functionality out of the box and if there is no particular reason that you need to use RadTextBox, please consider using RadNumericTextBox instead.
And just one more thing to add: If you experience some issues with RadNumericTextBox under Firefox 23 only, have in mind that this is still a beta version and not an official one (even though we have tested RadNumericTextBox under the latest Firefox Beta and no issues were present).
Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

Kaos45
Top achievements
Rank 1
answered on 09 Apr 2015, 08:13 PM
This worked like a charm, thanks much bro.