2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > jQuery Validation Engine验证模拟的下拉列表非select

jQuery Validation Engine验证模拟的下拉列表非select

时间:2019-03-15 06:16:20

相关推荐

jQuery Validation Engine验证模拟的下拉列表非select

select标签样式无法做到精美的地步,一般都用 span input等模拟出一个下拉列表,就可以做出各种精美的样式了。但是验证就有点纠结了,因为大家模拟的方法都不一样,所以Validation很难支持这种校验,在网上找了半天没有找到一个好的解决方法,自己做好后就想把这个方法分享给大家。

<tr><td>是否启用:</td><td><input id="isActive" name="isActive" class="validate[required]" data-prompt-position="topRight:145,222" type="hidden" /><div class="dropbox l selectBox selectBox-dropdown"><div class="dropbox-hd J-dropHd "><i></i><span id="isActiveSpan" class="J-sel selectBox-label">请选择</span></div><div class="dropbox-bdwrap J-dropBdWrap"><ul class="dropbox-bd "><li><a rel="启用" href="###" οnclick="javascript:$('#isActive').val('1')">启用</a></li><li><a rel="禁用" href="###" οnclick="javascript:$('#isActive').val('0')">禁用</a></li></ul></div></div></td></tr>

这是一个用span Ul 和LI模拟出来的下拉列表,使用一个隐藏的input来存储value。

注意的是这个其实是对隐藏的input校验。data-prompt-position是对偏移量设置 topRight 使用上右侧提示框样式,并且x,y定义偏移量。

<pre code_snippet_id="407935" snippet_file_name="blog_0627_3_3464332" name="code" class="javascript"><script type="text/javascript">$(function(){$("#dictionaryAddForm").validationEngine({showOnMouseOver: false,scroll:true,validateNonVisibleFields:true});});</script>

上面是声明form校验。

validateNonVisibleFields:true

这个属性是让插件校验隐藏的input。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。