1

I have an input for email and have validation for a@a but not have validation for .com.nz , .com, .org .sg

How to validate domain in email using jquery?

<input class="form-control" type="text" id="username" maxlength="100" name="username" required="required">
lakshman rajput
  • 511
  • 5
  • 14
airi
  • 585
  • 5
  • 21
  • [Discussed here](https://stackoverflow.com/questions/2507030/email-validation-using-jquery) Here is the link where it was already discussed. – rey Nov 05 '19 at 05:10

1 Answers1

1

Use custom validation rule

$.validator.addMethod("customemail", 
    function(value, element) {
        return /^([a-zA-Z0-9_.-+])+\@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(value);
    }, 
    "Sorry, I've enabled very strict email validation"
);
Reza Ghorbani
  • 2,396
  • 2
  • 28
  • 33
Asok Kumar
  • 11
  • 2