Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery验证检查工作不正常 $(文档).ready(函数(){ $(“.submit”)。单击(函数(){ if($('.district')[0]。selectedIndex_Jquery - Fatal编程技术网

jquery验证检查工作不正常 $(文档).ready(函数(){ $(“.submit”)。单击(函数(){ if($('.district')[0]。selectedIndex

jquery验证检查工作不正常 $(文档).ready(函数(){ $(“.submit”)。单击(函数(){ if($('.district')[0]。selectedIndex,jquery,Jquery,如果是表单提交,返回true将允许表单在以后执行javascript时提交表单,返回false将不会在javascript之后提交表单 现在关于jQuery验证,是的,您可以使用if($(“.class”).val()='')用于空或非选择如果是表单提交,则返回true将允许表单在以后执行javascript时提交表单,并且返回false将不会在javascript之后提交表单 现在关于jQuery验证,是的,您可以使用if($(“.class”).val()='')在if条件中为空或非选择,在

如果是表单提交,
返回true
将允许表单在以后执行javascript时提交表单,
返回false
将不会在javascript之后提交表单


现在关于jQuery验证,是的,您可以使用
if($(“.class”).val()='')
用于空或非选择

如果是表单提交,则
返回true
将允许表单在以后执行javascript时提交表单,并且
返回false
将不会在javascript之后提交表单


现在关于jQuery验证,是的,您可以使用
if($(“.class”).val()='')
在if条件中为空或非选择

,在错误消息之后,您可以使用return false避免表单提交

$(document).ready(function(){
    $(".submit").click(function(){
                if($('.disrtrict')[0].selectedIndex<=0){
                    $("#error1").html("district field is empty");

                } 

                if($(".block")[0].selectedIndex<=0){
                    $("#error2").html("block field is empty");  
                }


                if($(".village")[0].selectedIndex<=0){
                    $("#error3").html("village field is empty");    
                }

            });
});

如果您的第一个选项值为空,则上述代码将起作用。

在您的if条件中,在错误消息之后,您可以使用return false来避免表单提交

$(document).ready(function(){
    $(".submit").click(function(){
                if($('.disrtrict')[0].selectedIndex<=0){
                    $("#error1").html("district field is empty");

                } 

                if($(".block")[0].selectedIndex<=0){
                    $("#error2").html("block field is empty");  
                }


                if($(".village")[0].selectedIndex<=0){
                    $("#error3").html("village field is empty");    
                }

            });
});
如果您的第一个选项值为空,则上述代码将起作用。

您可以执行以下操作:

if($(".block").val()=="")
您可以这样做:

if($(".block").val()=="")

使用jQuery验证库,您不必编写该代码。它很容易使用,工作也很有魅力。有用于jQuery的验证插件。请考虑使用其中一个来简化您的生活。在您的脚本中没有任何<代码>返回false 。错误按摩不显示。在div标签中使用jQuery验证库,而您不必这样做。编写这个代码。它很容易使用,工作很有魅力。有可用的jQuery验证插件。考虑使用其中的一个来简化你的生活。在你的脚本中没有任何<代码>返回false 。错误按摩不显示。在DIV TAGCAN中,我们在$(“y.Error 1”)之后写返回false。html(“”);对于每一张支票,我们可以在$(“#error1”).html(“”)之后写return false吗;对于每次检查:-您对jquery很熟悉,先生,请解释我们何时何地使用return true和false。当您想要阻止点击事件和
表单
被提交时,请使用
return false
,当表单通过所有验证并且您想要
表单
被提交时,请使用
return true
在那之后提交。我希望你明白了!:-你对jquery很熟悉,先生,请解释我们何时何地使用return true和false。当你想阻止点击事件并阻止提交
表单时,请使用
return false
,当表单通过所有验证并且你需要时,请使用
return true
希望在那之后提交
表格
。我希望你能收到!