Reputation: 1
I'm trying to code a little Homepage with jQuery. It has a form and I want to check something with jQuery.
I have a textbox with the id points
.
jQuery has following code:
$(document).ready(function() {
setInterval(function() {
if ($("#points").value().length > 500) {
alert("Too many points!");
}}, 100)
});
But it doesn't work. Can someone help me?
Upvotes: -1
Views: 66
Reputation: 22998
I see two problems:
value()
in jQuery. It's val()
. For JavaScript, It is .value
.You are trying to get the length
of the number, which will give you 3
if the number was 123
.
$(document).ready(function() {
setInterval(function() {
if ($("#points").val() > 500) {
alert("Too many points!");
}
}, 100);
});
Upvotes: 1