user2915896
user2915896

Reputation: 3

Use form validation javascript only when browser can not validate form

Very basic and stupid question this might sound but i wanted to know if it is possible, if yes, then how.

These days, all new web browsers use HTML5 integrations, when i define

<input type="number" name="numericInput" />

<input type="email" name="email">

chrome / FF etc. will validate it for the input given, which would otherwise require some javascript or jQuery form validation methods.

What i want to know is, that, is there any method by which i can use form validation JS/jQuery only if these html5 features are not enabled in the browser for validation?
Thanks for any help!! :)

Upvotes: 0

Views: 551

Answers (1)

wmbtrmb
wmbtrmb

Reputation: 307

var hasBrowserValidation = (typeof document.createElement('input').checkValidity == 'function');

if(hasBrowserValidation){
    //validate form
} 

Upvotes: 2

Related Questions