SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Compare 2 Textboxes Not Working with Latest jQuery

    I have a form that requires the user to enter their email address twice to ensure they enter it correctly. jQuery 1.9.0 has caused the below code to stop working, can someone please help with the update?

    Code:
    <script type="text/javascript">
     jQuery(function(){
            $("#submit").click(function(){
            $(".error").hide();
            var hasError = false;
            var emailadrVal = $("#emailadr").val();
            var checkVal = $("#emailadr-check").val();     
      
    	  if(!  emailadrVal.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z.]{2,5}$/g) ){
    		alert('Please enter a valid email address.');
                hasError = true;
    		}
    	  
           	if (emailadrVal != checkVal ) {
                //$('#emailadr-error').html("Email addresses do not match.");
    			alert("Email addresses do not match. Please change.");
                hasError = true;
            }
           
    if(hasError == true) {return false;}
        });
    });  
    
    
    $(document).ready(function(){
          $('#emailadr-check').bind("cut copy paste",function(e) {
              e.preventDefault();
          });
        });	
    </script>
    The above code works fine with 1.3.2.

    THANKS!!

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,060
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    There's nothing there that I can see that should be causing an error.
    Can you post the HTML that goes with that jQuery (i.e. a short demo so that I can recreate your problem on my PC).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •