2014-03-31 3 views
-4

email address 필드와 confirm email address 필드를 가지고 있기 때문에 양식에 다음 유효성 검사를 사용하고 있습니다.이 두 필드가 일치하는지 확인하려면 몇 가지 유효성 검사가 필요합니다. 현재 다음을 제공합니다. 나도 그것이 할 때조차도 일치하지 않는다는 오류 메시지를, 누군가는 왜 그런지 알 수 있습니까?JQuery (전자 메일 일치)를 사용하여 전자 메일 유효성 검사

rules: { 
      'entry[email]': { 
       required: true, 
       email: true 
      }, 
      'entry[confirm_email]': { 
      // required: true, 
       equalTo: "entry[email]" 
      }, 
}, 
     messages: { 
      'entry[email]': { 
       required: ' Please enter a valid email address', 
       minlength: 'Not a valid email address' 
      }, 
      'entry[confirm_email]': { 
       required: ' Please make sure email matches above', 
       minlength: 'Does not match above email address' 
      }, 
    } 
+0

무엇이 오류입니까 ?? –

+0

내 이메일이 정확하게 일치하더라도 내게 그들이하지 않는 메시지를 전합니다 –

+0

jsfiddle을 만드십시오. –

답변

2

이러한 방식

rules:{ 
    pwd:{ 
     required:true //First email section 
    }, 
    pwd1:{ 
     required:true,//Second email section 
     equalTo: "#same" //Use id of the first email text box here 
     } 
    }, 
messages:{ 
    pwd1:{ 
     equalTo: "Must be same as above email" 
    } 
} 
사용해

Working Example 여기

0
$('#email).validate({ 
    ... 
    rules: { 
    ... 
    'entry[confirm_email]': { 
     equalTo: "entry[email]" 
    } 
    } 
}); 

"항목 [메일]"입력 요소의 ID되어야!

+0

_ "여기'entry [email]'는 입력 요소의 'id'여야합니다!"_ ~ ** 사실이 아닙니다! ** 유효한 jQuery 선택기 일 필요가 있습니다. 참조 : http://jsfiddle.net/6ux42/ – Sparky

관련 문제