在if语句中启用/禁用文本框的jquery [英] jquery for enable/disable textbox in if statement

查看:74
本文介绍了在if语句中启用/禁用文本框的jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人请为我提供Jquery的代码..





  • 如果tbfirstper == 100则tbsecondnominee,tbsecondper,tbthitdnominee,tbthirdper未启用。
  • 如果tbfirstper< 100;然后tbsecondnominee,tbsecondper启用,
  • 如果tbfirstper + tbsecondper< 100,则tbthitdnominee,tbthirdper is启用,
  • Any one please provide me the code for Jquery..


    • if tbfirstper==100 then tbsecondnominee,tbsecondper,tbthitdnominee,tbthirdper is not enable.
    • If tbfirstper <100;then tbsecondnominee,tbsecondper is enable,
    • if tbfirstper+tbsecondper<100, then tbthitdnominee,tbthirdper is enable,
    • <script type="text/javascript">
          $(document).ready(function () {
              $("#tbfirstper,#tbsecondnominee,#tbsecondper,#tbthitdnominee,#tbthirdper").blur(function () {
                  var v1 = $("#tbfirstper").val(),
                v2 = $("#tbsecondper").val();
                  if (!isNaN(v1)) {
                      if (parseInt(v1, 10) == 100) {
                          $("#tbsecondnominee,#tbsecondper,#tbthitdnominee,#tbthirdper").attr("disabled", true);
      
                      }
                      else if (parseInt(v1, 10) < 100) {
                          $("#tbthitdnominee,#tbthirdper").attr("disabled", true);
                          $("#tbsecondnominee,#tbsecondper").attr("disabled", false);
                      }
                      if (!isNaN(v2)) {
                          if ((parseInt(v2, 10) + parseInt(v1, 10)) == 100) {
                              $("#tbthitdnominee,#tbthirdper").attr("disabled", true);
                          }
                          else if ((parseInt(v2, 10) + parseInt(v1, 10)) < 100) {
                              $("#tbthitdnominee,#tbthirdper").attr("disabled", false);
                          }
                      }
                  }
              });
          });
      </script>



      但现在工作..当我在tbfirstper文本框中放入100时,其他texboxes不会被禁用..


      but this is now work..when i put 100 in tbfirstper text box then others texboxes is not disable..

      推荐答案

      document )。ready( function ( ){
      (document).ready(function () {


      #tbfirstper,#tbsecondnominee,#tbsecondper,#tbthitdnominee ,#tbthirdper)。模糊( function (){
      var v1 =
      ("#tbfirstper,#tbsecondnominee,#tbsecondper,#tbthitdnominee,#tbthirdper").blur(function () { var v1 =


      #tbfirstper)。val() ,
      v2 =
      ("#tbfirstper").val(), v2 =


      这篇关于在if语句中启用/禁用文本框的jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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