jQuery Validation plugin custom method using regex

前端 未结 2 1853
生来不讨喜
生来不讨喜 2021-01-28 17:40

I need to make a new method for jQuery Validator and don\'t know where to start.

I would like it check that the email entered includes: \'@specificdomain.com\'.

2条回答
  •  隐瞒了意图╮
    2021-01-28 18:10

    var s="abc@specificdomain.com";  OR  var s=value;
    var split = s.split('@');
    var regex = /^([a-zA-Z0-9_.+-])/;
    var s2="@specificdomain.com";
    
    if(regex.test(split[0]) &&  s2 == split[1])
    
           return true;
    else
             return false;
    

提交回复
热议问题