如何确保电子邮件条目仅限于一个条目;没有重复进入

时间:2016-03-03 04:18:59

标签: javascript jquery ajax validation email

功能

用户输入详情:

1。)姓名

2。)电子邮件

当用户点击提交时。将完成一些条件检查,以下条件检查功能是:

1。)验证电子邮件

  • 确保输入的电子邮件有效

2.。)验证空输入字段

3.)验证该条目不是重复条目

我做了什么:

我已经为前两项创建了条件检查。因此,我的条件检查能够验证电子邮件并验证任何空输入字段。

问题:

我有点坚持如何验证该条目不是重复条目。提交的企业将存储在数据库中,我使用ajax调用将字段输入到数据库中。

因此,任何人都可以帮助或指导我吗? 感谢

function Submit() {
  idleTime = 0;

  $("#email_wrong").hide();
  console.log($("#Options").val());
  if ($.trim($("#NameField").val()) == "" || $.trim($("#EmailField").val()) == "") {

    console.log("email wrong");
    $("#email_wrong").html("* Please fill in all fields.");
    $("#email_wrong").fadeIn();
  } else {
    if (validateEmail($("#EmailField").val())) {
      // Submit Photo Entry for Email Sending
      //ajax_submitForEmail("function.do", "formType=storeEmail&name=" + $.trim($("#name").val()) + "&email=" + $.trim($("#email").val()) + "&contact=&border=" + $.trim($("#txtBorderID").val()) + "&mediaURL=" + triggerVideoURL + "&projectID=" + triggerLibURL);
      console.log("correct fields");
      $('#EmailPage').fadeOut({
        duration: slideDuration,
        queue: false
      });

      //Method  call to slide and fade in second page to the left padding
      $('#TnC').fadeIn({
        duration: slideDuration,
        queue: false
      });
    } else {
      $("#email_wrong").html("* Please enter a valid email address.");
      $("#email_wrong").fadeIn();
    }
  }
}

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);
}
<div id="EmailPage" align="center" style="position:absolute; width:1080px; height:1920px; background-repeat: no-repeat; display: none; z-index=2; top:0px; left:0px; ">


  <table align="center" cellspacing="0" cellpadding="0" width="1080" top="550px">
    <tr style="height: 1920;">
      <td width="1080">
        <div id="email_wrong" style="z-index:3; position:absolute; top:600px; left:170px; display: none; font-size:30px; font-family:'CenturyGothic'; width:1080; color:#000000;"><font face="CenturyGothic">* Please fill in all fields.</font>
        </div>

        <img id="Name" src="lib/Name.png" />
        <input type="text" id="NameField" style="position:absolute; top:650px; left:385px; height:63px; width:530px; outline=0px; border: 0; font-size:25px; font-family:'CenturyGothic'; background: transparent; z-index:100;" autofocus src="lib/transparent.png">

        <img id="Email" src="lib/Email.png" />
        <input type="text" id="EmailField" style="position:absolute; top:750px; left:385px; height:63px; width:530px; outline=0px; border: 0; font-size:25px; font-family:'CenturyGothic'; background: transparent; z-index:100;" src="lib/transparent.png">
        <button id="Submit" onclick="Submit()">
          <img src="lib/SubmitButton.png">
        </button>
      </td>
    </tr>
  </table>

</div>

0 个答案:

没有答案