jQuery Validation Tooltip

When my text input doesn’t validate as an email address I want a tooltip to show. The jQuery code below doesn’t work. Can anyone help me with this?

Here is the code:

    <script language="javascript" type="text/javascript">
    	 
    $(document).ready(function() {

    $('.email').focusout(function(){

                  $('.email').filter(function(){
                  var emil=$('.email').val();
                  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
                if( !emailReg.test( emil ) ) {	
    			$(this).tooltip({
      content: "<div style=\"position: relative; top: -20px; right: -500px; background-color: #444; padding: 6px; width: 180px; height: 60px; color: #fff;\">Please enter a valid email address.</div>"});
                    }
                    })
                });

    });

    </script>
<input type="email" class="ui-tooltip-content email" id="tooltip-1" name="tooltip-1" size="61">

The html didn’t show up. Here it is:

<input type="email" class="ui-tooltip-content email" id="tooltip-1" name="tooltip-1" size="61">

That HTML performs proper validation of the email address entered - you don’t need to add JavaScript that will reject most valid email formats as invalid.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.