Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery how to check if a input has a number higher then 99

Tags:

jquery

Was wanting to know how to check using jquery if a input contains a number higher then 99

like image 948
Lawrence Avatar asked Nov 28 '22 22:11

Lawrence


2 Answers

try this:

if(parseInt($("selector").val()) > 99) {
    /*if it is*/
}

or if you are checking it on change:

$("selector").change(function(){
     if(parseInt(this.value) > 99){
        /*if it is*/
     } 
})

Edit as said in the below comments, it might be better to use parseFloat instead of parseInt to compare the numbers

like image 191
Naftali Avatar answered Dec 15 '22 06:12

Naftali


if ($("#myfield").val() > 99) {

}
like image 23
Gerben Jacobs Avatar answered Dec 15 '22 06:12

Gerben Jacobs