2014-09-19 24 views
1

我正在使用BootstrapValidator驗證我的電子郵件輸入框。它完美的工作,但是我想通過驗證來實現某個電子郵件域「@ test.com」,我該怎麼做?阻止特定電子郵件域上的BootstrapValdiation

這裏是代碼:

email: { 
       message: 'Your email must be in the format "[email protected]"', 
       validators: { 
        notEmpty: { 
         message: 'Your email is required and cannot be empty' 
        }, 
        emailAddress: { 
         message: 'The value is not a valid email address' 
        } 



       } 
      }, 

回答

1

您可以使用正則表達式來排除test.com域:

email: { 
      validators: { 
       notEmpty: { 
        message: 'The email address is required and cannot be empty' 
       }, 
       emailAddress: { 
        message: 'The email address is not a valid' 
       }, 
       regexp: { 
        regexp: /^(([email protected]\.com).)*$/, 
        message: 'The test.com domain is invalid' 
       }, 
      } 
     } 

我修改這個小提琴引導驗證示例,所以你可以看到它的工作: http://jsfiddle.net/pLt295eh/

+0

非常感謝你的朋友 – 2014-09-19 19:13:22

相關問題