jQuery Tooltip Custom implementation -


i working application generating html forms, , including custom attributes used client side validation. error message used validation, included in error attribute, , expression validate input against, included in expression attribute.

i have following javascript block,

$(document).ready(function() {   $("input[expression]").blur(function() {     var inputs = $(":input[expression]");     inputs.each(function(index){         var input = inputs[index];         var expression = $(this).attr('expression');        if(!$(this).val().match(expression))        {         var error = $(this).attr("error");         $(this).attr("title",error);         $(this).tooltip({ position: "center right", opacity: 0.7});         $(this).tooltip().show();        }        else        {        }    });   });  });  

what attempting setup fields expression attribute validate expression value against current value when input box, loses focus.

this sort of working right now, not behavior have.

right now, tooltip error message popping when click on input element. not want this, want show error message following running through blur() callback function.

is there correct way this?

an example of markup shownbelow

<input type='text' name='firstname' expression='[a-za-z]' error='please enter first name'/> 

your event firing every input when blur out of any input. regex wrong.

jquery(document).ready(function() {              jquery("input[expression]").blur(function() {                 if(jquery(this).val().search(jquery(this).attr('expression')) == -1)                 {                     var error = jquery(this).attr("error");                     jquery(this).attr("title",error);                     jquery(this).tooltip({ position: "center right", opacity: 0.7});                     jquery(this).tooltip().show();                 }             });          });  

and regex should this: ^[a-za-z]*$


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -