Jquery value does not match format

I would like to check the input field and check if the time value matches 06:15

But where should the statement be .not

?

($("#id").val().not.match(/^(2[0-3]|[01][0-9]):[0-5][0-9]$/))

      

+3


source to share


1 answer


In this case, you shouldn't use .not

.

A .not

jQuery function requires a parameter Selector

, Element

or Array

for example:

$( "li" ).not( ":even" );

      



As mentioned in Arun P Johny

the comments, the best way is to use the boolean operator NOT

: !

to perform boolean negation in your expression:

if(!$("#id").val().match(/^(2[0-3]|[01][0-9]):[0-5][0-9]$/)) {
    //not matching with the regExp
}

      

0


source







All Articles