This rule cannot tell if there is a space at the end.

var reg = /(^1[3456789]\d{9}$)|(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/
reg.test("13807011234                                  ");   //false
reg.test("111@qq.com                                 ");   //true


var reg = /(^1[3456789]\d{9}$)|(^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$)/

this rule is used to determine whether the mobile phone number or mailbox

when judging the mobile phone number, he has a space at the end and normally returns false
, but when judging the mailbox, the space at the end returns true,. What I need is false

.

what I need is to fail the regular judgment and directly prompt the format error, not to use the trim function to ignore spaces and submit the form

.

start and end with ^ and $, you write not only the space at the end of the line, but also the space at the beginning of the line will pass

.
Menu