1
I have a input
of the kind number
, and I would like it to accept only whole numbers.
Hence I am creating a function that limits the number of characters and replaces the digit that is not number with replace.
The problem, that this type of input accepts some characters like: "e+.,-"
. But when I try to get the value, it comes empty when typed something other than a number. So I can’t replace the characters.
$("[type=number]").val();
Regardless of whether there are other ways to do this by locking key, using input text etc. My question is:
Is there any way to get the value typed in the field INPUT NUMBER
, instead of this blank value when typed characters other than numbers?
Precisely because of this, html itself filters the value. When you send the data it sends the data with special character?
– Glenys Mitchell
@Glenysmitchell When I trigger the keyup event, it returns an empty variable " " ... Any character other than number returns empty. Hence it is not possible to replace. A few days ago I read something about default value... but I do not remember the difference, and if I doubt.
– abcd
Already tried to rescue (same empty) and rewrite the field?
– Glenys Mitchell
Do you speak store in a variable the previous value? and if it comes empty, I return with the previous value?
– abcd
This, so if he enters a special character when he returns the empty value will erase the character.
– Glenys Mitchell