javascript - combinate input-fields for Livevalidation -


i check input fields livevalidation if not empty. using following code:

        <script type="text/javascript">             var street = new livevalidation('street');             var streetnumber = new livevalidation('streetnumber');             street.add( validate.presence );             streetnumber.add( validate.presence );         </script>  

the both input-filds inline. message directly displayd behind input-field. now, message first input-field reposition second field.

i looking best way combinate validation 2 fields , shown 1 message.

here can see actual result: http://jsfiddle.net/vme7c/

http://jsfiddle.net/vme7c/1/

var street = new livevalidation('street',{     onvalid:showmessage(true),oninvalid:showmessage(false) }); var streetnumber = new livevalidation('streetnumber',{     onvalid:showmessage(true),oninvalid:showmessage(false) });  var streetvalid=false,streetnumbervalid=false,     ls=document.getelementbyid('msgli'); function showmessage(val){     return function(){         if(this.element.id=="street")             streetvalid=val;         else             streetnumbervalid=val;         if(streetvalid && streetnumbervalid){             ls.innerhtml="all fields valid";             return;         }         if(!streetvalid && !streetnumbervalid){             ls.innerhtml="no field valid";             return;         }         ls.innerhtml=(!streetvalid?"street":"street number")             +" field invalid";         return;     } }  street.add(validate.presence); streetnumber.add(validate.presence); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -