我有一个
JavaScript来检查字段是否等于15个字符,如果不是,则提交按钮是灰色的.如果我手动输入15个字符,这很好地工作,但如果我粘贴15个字符则不行.即使内容粘贴在字段中,如何检查?
我可以定期(秒)检查字符,还是有“检查粘贴”的功能?
我的剧本:
<script type="text/javascript"> jQuery(document).ready(function($){ $('input[type=submit]').attr("disabled","disabled"); $('input[name="item_Meta[1234]"]').keypress(function() { //change # to the ID of your field if (document.getElementById("field_ygtw9u").value.length < 14) { //disable submit if "no" is selected $('input[type=submit]').attr("disabled","disabled"); } else { //enable the submit button $('input[type=submit]').removeAttr('disabled'); } }); }); </script> <form> <div id="frm_field_1234_container" class="frm_form_field form-field frm_required_field frm_top_container"> <label class="frm_primary_label">Minimun 15 char: <span class="frm_required"></span> </label> <input type="text" id="field_ygtw9u" name="item_Meta[1234]" value="" maxlength="15" class="required"/> <p class="submit"> <input type="submit" value="Submit" /> </p> </form>
解决方法
将按键更改为键盘,它应该工作.
原文地址:https://www.jb51.cc/js/158252.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。