如何避免在文本框中进行退格验证

编程入门 行业动态 更新时间:2024-10-26 04:24:06
本文介绍了如何避免在文本框中进行退格验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个文本框并完成了验证,没有输入任何字段,我将无法进入第二个文本框。但现在的要求是,如果我按退格键并进入选项卡按钮意味着字段级别验证不起作用,即它移动到第二个文本框。 我使用的代码

< script type = text / javascript src = ../ assets / global / plugins / jquery -validation / JS / jquery.validate.min.js>< /脚本> < script type = text / javascript src = ../ assets / global / plugins / jquery-validation / js / additional-methods.min.js>< /脚本> < script src = ../ assets / admin / pages / scripts / form-wizard.js >< /脚本> < script type = text / javascript> $()。ready( function (){ $('' #PageContent_txt_Propertytypename')。focus( function (){ name_propertytype = document .getElementById(' PageContent_txt_Propertytypename')。value; if (name_propertytype == ' ' ){ $(' 。fld1-error')。html( 此字段是必需的'); $(' #PageContent_txt_Propertytypename')。css(' border -color',' red'); document .getElementById(' PageContent_txt_Propertytypename')聚焦(); return false ; } else { $(' .fld1-error')。html(' '); $(' #PageContent_txt_Propertytypename')。css(' border-color',' 绿色); } }); }); < / script>

谢谢和问候 MGBalamurugan

解决方案

()。ready( function (){

(' #PageContent_txt_Propertytypename')。focus( function (){ name_propertytype = document .getElementById(' PageContent_txt_Propertytypename')。value; if (name_propertytype == ' '){

(' .fld1-error')。html(' 此字段必填');

Hi, I have a textbox and done the validation in that without entering any fields I won't be able to enter the second textbox. But now the requirement is if I'm pressing backspace and entering the tab button means field level validation is not working i.e it moves to the second textbox. The code I used

<script type="text/javascript" src="../assets/global/plugins/jquery-validation/js/jquery.validate.min.js"></script> <script type="text/javascript" src="../assets/global/plugins/jquery-validation/js/additional-methods.min.js"></script> <script src="../assets/admin/pages/scripts/form-wizard.js"></script> <script type="text/javascript"> $().ready(function () { $('#PageContent_txt_Propertytypename').focus(function () { name_propertytype = document.getElementById('PageContent_txt_Propertytypename').value; if (name_propertytype== '') { $('.fld1-error').html('This field is required'); $('#PageContent_txt_Propertytypename').css('border-color', 'red'); document.getElementById('PageContent_txt_Propertytypename').focus(); return false; } else { $('.fld1-error').html(''); $('#PageContent_txt_Propertytypename').css('border-color', 'green'); } }); }); </script>

Thanks and Regards M.G.Balamurugan

解决方案

().ready(function () {

('#PageContent_txt_Propertytypename').focus(function () { name_propertytype = document.getElementById('PageContent_txt_Propertytypename').value; if (name_propertytype== '') {

('.fld1-error').html('This field is required');

更多推荐

如何避免在文本框中进行退格验证

本文发布于:2023-10-28 05:17:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535636.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框中   文本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!