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. The sample email is xx-xx-xx@ciit-atk.edu.pk
and any other email not having the same domain will not be accepted. 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. I have this regex "^[\w-\._\+%]+@(ciit-atk.edu.pk)"
but it's not working.
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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.