Reputation: 149
I have this jQuery which automatically adds a dot on thousand:
$(function () {
$(document).on("keyup", "input[type=text]", function () {
if (event.which >= 37 && event.which <= 40) return;
// format number
$(this).val(function (index, value) {
return value
//doadaje tacku na hiljade:
.replace(/\D/g, "")
.replace(/\B(?=(\d{3})+(?!\d))/g, "\.")
;
});
})
})
On my form I have one textbox for date and all others textboxes are for numerical input. I want to restrict this jQuery to works only with textboxes for numerical input. Now this jQuery formatting and textbox for date but I don't want to do that on that field.
Upvotes: 0
Views: 39
Reputation: 23
you can access to input by class
$(document).on("keyup", "input[type=text]", function () {
Upvotes: 1
Reputation: 50316
Each textbox has his own ID name
I will rather suggest to use an identifier to distinguish between inputs which will accept only number. Then use this class to trigger event
$(function () {
$(document).on("keyup", "input[class=onlyNum]", function () {
//Rest of code
})
})
Upvotes: 1