如何避免在文本框中进行退格验证 [英] How to avoid backspace validation in textbox

查看:70
本文介绍了如何避免在文本框中进行退格验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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





我使用的代码

< 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 (){
$('' < span class =code-string>#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');


这篇关于如何避免在文本框中进行退格验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆