javascript返回false的问题 [英] problem of javascript on returning false

查看:47
本文介绍了javascript返回false的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< script language = "  type = " >
      函数 JobDetailsValidation()
      {
      调试器 var  Position = 文档 .getElementById("  txtPosition").value;
       var  KeySkills = 文档 .getElementById("  txtKeySkills").value;
       var  JobDescription = 文档 .getElementById("  txtJobDiscription").value;
       var  JobLocation = 文档 .getElementById("  txtJobLocation").value;
      如果(位置==空||位置== "  || KeySkills == null || KeySkills ==  " || JobDescription = = null || JobDescription == "  || JobDescription == null || JobDescription == "  || JobLocation ==空|| JobLocation == " ")
     {
       alert(" );
       返回 ;
     }
     其他
          {
            ExperienceValidation()
          }
      }
      功能 ExperienceValidation()
      {
       var  Experience = 文档 .getElementById("  DropDownList1").value;
       var  Experience1 = 文档 .getElementById("  DropDownList2").value;
       var  CTC = 文档 .getElementById("  DropDownList3").value;
       var 级别= 文档 .getElementById("  DropDownList4").value;
       var  Gender = 文档 .getElementById("  DropDownList5").value;
      如果(经验==空||经验== "  || Experience1 == null || Experience1 ==  " || CTC = = null || CTC == "  || Level == null || Level == "  || Gender ==空|| Gender == " ")
          {
             alert(" );
             返回 ;
          }
     返回 ;
      }
      </script> 





我在javascript中使用了此代码,但是我的问题是当ExperienceValidation()函数运行并且返回false时,请求仍在服务器端进行.请帮助我,并提前感谢

解决方案

当您从Button调用javascript时给出"返回",请检查以下内容

 <   asp:button     id   ="     runat   =" 服务器" 文本  检查"  onclientclick   ="     xmlns:asp   ="  span> >  <  /asp:button  >  


您可以尝试使用OnClientClick

有关更多信息,请参见 http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.button.onclientclick.aspx [<script language="javascript" type="text/javascript"> function JobDetailsValidation() { debugger; var Position=document.getElementById("txtPosition").value; var KeySkills=document.getElementById("txtKeySkills").value; var JobDescription=document.getElementById("txtJobDiscription").value; var JobLocation=document.getElementById("txtJobLocation").value; if(Position==null||Position==""||KeySkills==null||KeySkills==""||JobDescription==null||JobDescription==""||JobDescription==null||JobDescription==""||JobLocation==null||JobLocation=="") { alert("Job Details name must be filled out"); return false; } else { ExperienceValidation() } } function ExperienceValidation() { var Experience=document.getElementById("DropDownList1").value; var Experience1=document.getElementById("DropDownList2").value; var CTC=document.getElementById("DropDownList3").value; var Level=document.getElementById("DropDownList4").value; var Gender=document.getElementById("DropDownList5").value; if(Experience==null||Experience==""||Experience1==null||Experience1==""||CTC==null||CTC==""||Level==null||Level==""||Gender==null||Gender=="") { alert("Please Select All Details Of Experience Section"); return false; } return false; } </script>





I uses this code in javascript,but my problem is when the function ExperienceValidation() run and when it returns false the request is still going on the server side.Please help me and thanks in advance

解决方案

when you calling javascript from Button give "return" , check below

<asp:button id="btnOne" runat="server" text="check" onclientclick="return JobDetailsValidation()" xmlns:asp="#unknown"></asp:button>


You can try with OnClientClick

for more info see
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclientclick.aspx[^]


- Nilesh


i got the mistake,whenever my ExperienceValidation() was called it returns false but i am not catching the return value at the point from where the function is called


这篇关于javascript返回false的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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