You are viewing limited content. For full access, please sign in.

Question

Question

How to Apply This Jquery to added rows in a table

asked on May 5, 2017

I have been trying to apply this code to the added rows of a table, but I can't seem to get it to work. The code is suppose to disable the submit button and display a message saying "Each Line Item must be equal to or greater than $5000" to any column under the Commitment Amount when an amount less than 5000 is placed in the field value. If the value is 5000 or greater the error goes away. I can get to work with the first row, but not with the other added rows to the table. May I please get some assistance 

 

Here is the code I am using and a screen shot of the form and what I'm trying to do. 

Code:

$('[id^=Field573]').on('change', function () {
     console.log("test: " + $(document.activeElement).val() + "  " + this.id)

        if ($(this).val() < 5000) {
            $('.Submit').attr("disabled", "disabled");
            if ($('.warningText').length > 0 || $('.sum input').val() >= 5000){
                return; 
            } else {
                $('<p class="warningText"><font color="red"><b>Each Line Item must be equal to or greater than $5000.</b></font></p>').insertAfter(this);
            }
        }
        else
            $('.warningText').remove();
        $('.Submit').removeAttr('disabled');

    });
  

Forms Jquery.JPG
Form with Identifers.JPG
Forms Jquery.JPG (84.38 KB)
0 0

Answer

SELECTED ANSWER
replied on May 8, 2017

My co-workers and I figured it thank you for all the help. 

0 0

Replies

replied on May 8, 2017

I added a Css Class called "currencyrange to the currency field" and disabled the "use thousand delimiter" checkbox and use following JavaScript:

$(document).on('change','.currencyrange input', function () {
 console.log("test: " + $(document.activeElement).val() + "  " + this.id)

        if ($(this).val() < 5000) {
             $('.Submit').attr("disabled", "disabled");
             //check whether there is warning for current row
             if ($(this).siblings('.warningText').length > 0 || $('.sum input').val() >= 5000){
                 return; 
             } else {
                 $('<p class="warningText"><font color="red"><b>Each Line Item must be equal to or greater than $5000.</b></font></p>').insertAfter(this);
             }
         }
         else
         {
             $(this).siblings('.warningText').remove();        
         }
  //only enable the submit button when there is no warning
         if($('.warningText').length <= 0)
           $('.Submit').removeAttr('disabled');
    });
 
     

 

0 0
replied on May 8, 2017

Xiuhong,

 

Thank you for taking the time to work this. Did you add the .currencyrange CSS class to the currency on top of the .sum css class? See screenshot. 

New Jquery Script.JPG
0 0
replied on May 8, 2017

This is the entire code and it isn't working at all. 

 

//phonemask-------------------------------------------------
$(document).ready(function () {
  $.getScript
  ('http://localhost/Forms/js/jquery.mask.min.js',
    function () {
      $(".phone input").mask("(999)-9999");

    });
  
  //$('.lockField input').attr('readonly',true);

  $(document).on('blur change', '.sum input', sumtotal);
  function sumtotal() {
    var s = 0;
    $('.sum input').filter(':visible').each(function () {
      s += parseNumber($(this).val());
    });
    $('.total input').val(s);
  }
  function parseNumber(n) {
    var = f = parseFloat(n); //Convert to float number.
    return isNaN(f) ? 0 : f; //treat invalid input as 0;
  }
  //sum $ amount confirmation 
  $(document).on('change','.currencyrange input', function () {
    console.log("test: " + $(document.activeElement).val() + " " + this.id)

    if($(this).val() < 5000) {
      $('.Submit').attr("disabled", "disabled");
      //check whether there is warning for current row
      if ($(this).siblings('.warningText').length > 0 || $('.sum input').val() >= 5000){
      return;
      } else {
        $('<p class="warningText"><font color="red"><b>Each Line Item must be equal to or greater than $5000.</b></font></p>').insertAfter(this);
      }
    }
    else
    {
      $(this).siblings('warningText').remove();
    }
    //Only enable the submit button when there is no warning
    if($('.warningText').length <= 0)
      $('.Submit').removeAttr('disable');
  }
}
                

    


 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.