Reputation: 76564
I have the following code:
jQuery(document).ready(function ($) {
// ...
Sys.Application.add_load(function () {
$(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled").each(function () {
$(this).val($(this).val().replace(/,/g, ""));
});
$(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled").blur(function () {
$(this).val($(this).val().replace(/,/g, ""));
});
});
}
The reason I have written this code is that I'm using Telerik RadGrid which has some autogenerated columns and a column filter, which formats the value of integer column filter values. For example 1000000 becomes 1,000,000. It works fine, but I have to get rid of the formatting because it bothers some people. Essentially the HTML elements we are talking about are inputs and they are modified by telerik and can be found with the selector you see in the code. I want to make sure that the users will never see comma in these inputs. My code works well in google Chrome, FF and IE9, but it fails to work with IE8 and IE7. In fact after loading my page I don't see commas, however, if I edit them end focus out of the items, the commas appear. These issues are applicable only in IE8 and IE7. How can I fix my code to work in Chrome, FF, IE9, IE8 and IE7?
Thank you in advance for any help.
Best regards,
Lajos Árpád.
Upvotes: 0
Views: 2267
Reputation: 17367
From the JQuery documentation:
The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as <input>. In recent browsers, the domain of the event has been extended to include all element types.
So if, as I guess, riTextBox is a class of some span containing an input, this should work:
$(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled input")
.blur(function () {
$(this).val($(this).val().replace(/,/g, ""));
});
Upvotes: 1