我正在使用以下标签 - 它插件:http://widen.github.io/jQuery-Tagit/.
我想验证标签,输入将是电子邮件地址.我怎样才能做到这一点?
我的代码:
HTML
JavaScript(jQuery)
$(document).ready(function () { $('#editOnClick > ul').tagit({ select:true, triggerKeys:['comma', 'enter', 'space', 'semicolon', 'tab'], tagSource:"view_email_get_emails.php", editOnClick:true beforeTagAdded: function(event, ui) { return isEmail($('#email').tagit("tags"))} }); function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } }); });
我将我的代码添加到JSFiddle.