开发者

Creating a character restriction on an email field

开发者 https://www.devze.com 2023-03-04 13:48 出处:网络
Hey. I\'m creating an input field (<input type=\"text\" value=\"\" />) that my user will enter thei开发者_运维问答r email in, but I am also using a live alphanumeric character restriction on tha

Hey. I'm creating an input field (<input type="text" value="" />) that my user will enter thei开发者_运维问答r email in, but I am also using a live alphanumeric character restriction on that field (in jQuery) with the exception of the characters, .!#$%&'*+-/=?^_{|}~@. I'm wondering if it is worth it to do all this checking, or to just say "Hey, invalid email" when they hit submit? Thanks in advance!


It's not something you need to do in a given way, entirely your choice, but I think it's helpful for a user to get the error while filling a form and not after it, so he should go back and change it, it's a bit more time consuming. I personally did this on every registration form I've done.

If you mean only server side check under "when they hit submit" then you should really do a jquery check on the input as well, you spare traffic with it, also you need to do both server side and client side checking.


I prefere to use mask for formated fields like phones or emails, that way you sensure the format and the user won't get lost on what to input.

May you take a look at this:

http://jquery-ui.googlecode.com/svn/branches/labs/mask/demos/mask/default.html

http://wiki.jqueryui.com/w/page/12137996/mask


How about not restricting the characters, but rather checking the value against a simple regexp? You can do this live. This is an interesting article: http://www.regular-expressions.info/email.html I would still check it after submission, some users may have JS disabled.

0

精彩评论

暂无评论...
验证码 换一张
取 消