简体   繁体   English

欧芹验证中带有自定义域的 email 的正则表达式是什么

[英]what will be regular expression for email with custom domain in parsley validation

I have a form on which I want to apply parsley validation.我有一个表格,我想在上面应用欧芹验证。 I want to allow only email with domain @ciit-atk.edu.pk but I don't have a regex for it that will work with parsley validation.我只想允许域@ciit-atk.edu.pk的 email 但我没有适用于欧芹验证的正则表达式。 The sample email is xx-xx-xx@ciit-atk.edu.pk and any other email not having the same domain will not be accepted.样本 email 是xx-xx-xx@ciit-atk.edu.pk和任何其他不具有相同域的 email 将不被接受。 I don't want a generic regex, I need a regex for this specific domain that will work with parsley validation.我不想要一个通用的正则表达式,我需要一个适用于欧芹验证的特定域的正则表达式。

<input type="email" class="form-control" name="email" placeholder="Email..." required data-parsley-pattern="" data-parsley-trigger="keyup" >

The regex will go in data-parsley-pattern field.正则表达式将 go 在data-parsley-pattern字段中。 I have this regex "^[\w-\._\+%]+@(ciit-atk.edu.pk)" but it's not working.我有这个正则表达式"^[\w-\._\+%]+@(ciit-atk.edu.pk)"但它不起作用。

Try this:尝试这个:

 let emailTrue = 'xx-xx-xx@ciit-atk.edu.pk'; let emailFalse = 'asd@gmail.com'; let emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(ciit-atk.edu.pk)$/; console.log(emailRegex.test(emailTrue)); console.log(emailRegex.test(emailFalse));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM