javascript - Show HTML5 validation message -


i'm using html5 constraint validation , i'd show validation message after each blur.

html

<input id="texinput" type="text" onblur="validation()" required> 

js

var el = document.getelementbyid('texinput'); if (!el.checkvalidity()) {     //here show message }  

is possible similar?

valid-massage

it possible. this:

html:

<input id="texinput42" type="text" onblur="function(){validation('texinput42');}" required> 

js:

function validation(_id){     var isvalid= false;     //check validity here:     var el = document.getelementbyid(_id);     if(el.innerhtml == '') isvalid=false;      if(el.innerhtml.length > 0) isvalid=true;       if (isvalid) {       //here show message       alert('debug: it's ok');       //or change css color el in green, e.g.     } }  

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -