How can I allow only gmail.com as domain in my email field validating using jquery-validation plugin?

前端 未结 3 1885
清歌不尽
清歌不尽 2020-12-12 05:27

How can I allow only gmail.com as domain in my email field validating using jquery-validation plugin ?

$(\"#myForm\").validate({
rules: {
    myemail: {
             


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 06:24

    You have to write a regular expression that accepts strings ending with 'gmail.com'

    Check here for regex on Gmail address:

    Regular Expression - Validate Gmail addresses

    Check here on how to add regexp validation:

    jQuery validate: How to add a rule for regular expression validation?

提交回复
热议问题