I have create the form with selection option. Based on the selection i show and hide form field.... How to validate the mobile no. If the user enter same mobile no again then throw the error message. How to find the mobile duplication entry

我已经创建了带有选择选项的表单。基于选择我显示和隐藏表单字段....如何验证移动号码。如果用户再次输入相同的移动设备,则抛出错误消息。如何查找移动复制条目

$(document).ready(function() {
 $('#hidden-div').hide();
 $("#select_btn").change(function() {
    toggleFields();
  });
  });

function toggleFields() {
  var selectVal = $("#select_btn").val();
  if (selectVal <= 5) {
    $hiddenHtml = $('#hidden-div').clone().html();
    $("#refer").html('');
    for (var i = 0; i < selectVal; i++) {
      $("#refer").append($hiddenHtml);
    }
  }
}

function InvalidMsg(textbox) {

     if(textbox.validity.patternMismatch){
        textbox.setCustomValidity('please enter valid mobile number');
    }    
    else {
        textbox.setCustomValidity('');
    }
    return true;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<html>
<head>
<title> Demo </title>
<meta name="robots" content="noindex, nofollow" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id ="refer-form" name="refer-form"   method="post" >
 
  <p>No of Referrer:
    <select id="select_btn" onchange="toggleFields();">
      <option value="0">--Select--</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <div id="hidden-div">
 <div id="text">Referrer</div>
      <p>Name:
        <input type="text" name="name[]" class="name"/>
      </p>
      <p>Mobile:
        <input type="text" name="mobile[]" class="mobile" oninvalid="InvalidMsg(this);" />
      </p>
      <p>Email:
        <input type="text" name="email[]" />
      </p>
      
    </div>
    <div id="refer">

    </div>
    <p align="center">
      <input type="submit" value="Submit" />
    </p>
</form>

更多相关文章

  1. 使用PHP显示所有列条目
  2. 提交动态复选框表单并成对获取值
  3. 仅在LARAVEL或AJAX中提交表单时,无需用户身份验证即可将文件上载
  4. 来自php表单的样式电子邮件
  5. 请问如何用php实现表单提交后以邮件的形式把表单内容发到邮箱中
  6. 如何在jQuery Mobile页面中提交表单?
  7. Symfony2 -从数据库中提取数据并以表单形式显示
  8. laravel 框架自带表单验证
  9. AJAX学习之提交表单

随机推荐

  1. 在h:inputTextarea中阻止Html标记
  2. jquery入门-$.each 数组操作与表单操作代
  3. 穹顶之下-善恶是非谁来负责
  4. HTML设置的横跨3列
  5. .fadeToggle()使我的子列表不可访问
  6. 如果字符串包含html代码,如何用python检测
  7. 去除Chrome浏览器文本框边缘的黄线
  8. 【竞价网站绝技】根据访客ip,页面显示访客
  9. Html css缩放会将大小改变几个像素
  10. 利用HTML5开发Android笔记