jquery单选按钮验证

时间:2011-08-24 05:35:30

标签: javascript jquery

我正在使用单个搜索选项字段,通过单击该页面上给出的单选按钮以不同方式进行搜索。例如,通过search-client-by-id,search-client-by-name,search-client-by-emailid等搜索,我想通过点击不同的单选按钮在同一个搜索字段上对其进行不同的jQuery验证

用于此目的的验证就像这个演示: http://www.position-relative.net/creation/formValidator/demos/demoValidators.html

<div class="search-job-txtbox" >
      <input type="text" name="clientSearchText" id="clientSearchText" value="" class="search-txtbox" onkeyup="javascript:searchByCriteria(this.value,'radio');"/>
      <div class="search-icon"><a href="javascript:;"><a href="javascript:;"><img src="<%=request.getContextPath()%>/images/search-icon.gif" width="25" alt="Search" title="Search" height="25" /></a></div>
    </div>
    <div class="job-options">
      <div class="job-checkbox"><input type="radio" name="radio" id="radio" value="search-client-by-id" checked="true" onclick="javascript:searchByCriteria();"/></div>
    <h5>ID</h5>
    <div class="job-checkbox"><input type="radio" name="radio" id="radio" value="search-client-by-name" /></div>
    <h5>Name</h5>
    <div class="job-checkbox"><input type="radio" name="radio" id="radio" value="search-client-by-emailid" /></div>
    <h5>Email</h5>
     <div class="job-checkbox"><input type="radio" name="radio" id="radio" value="search-client-by-contact-number" /></div>
    <h5>Contact</h5>
    </div>

1 个答案:

答案 0 :(得分:0)

您可以动态触发验证

$('input.clientID').click(function() {
   $('#form').validationEngine(options);
});

为每种类型执行此操作,或实现案例/开关