在一个文本框中验证几封电子邮件

时间:2016-03-16 08:31:24

标签: javascript jquery

我需要验证几封电子邮件,哪些用户键入了按键电子邮件。电子邮件必须只用逗号或退格和逗号分隔。我有电子邮件验证功能

  [libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.SolverParameter: 1:5: Message type "caffe.SolverParameter" has no field named "name".  
    F0316 15:57:16.892113  3464 upgrade_proto.cpp:1063] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse SolverParameter file: examples/corel5k/auto_train.prototxt
    *** Check failure stack trace: ***
        @     0x7f79b3a4011d  google::LogMessage::Fail()
        @     0x7f79b3a41fbd  google::LogMessage::SendToLog()
        @     0x7f79b3a3fd38  google::LogMessage::Flush()
        @     0x7f79b3a4281e  google::LogMessageFatal::~LogMessageFatal()
        @     0x7f79b4065ee7  caffe::ReadSolverParamsFromTextFileOrDie()
        @           0x40a8c5  train()
        @           0x407544  main
        @     0x7f79b25a0ec5  (unknown)
        @           0x407615  (unknown)
    Aborted (core dumped)

我想我必须写这样的东西,但我不知道接下来要做什么

function validateEmail(email) {
    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
} 

1 个答案:

答案 0 :(得分:0)

将您的事件处理程序更改为

$('textbox').on('keypress change keyupp', function(e){
      var badEmails = this.value.split(",").filter(function(val){return !validateEmail(val) });
      if( badEmails.length  > 0 ) )
      {
        return false;
      }
});