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

Question

Question

Error alert for value exceeded is not working

asked on February 23, 2018

Trying to test for percentage value not to exceed 100.  My code is below.  I am using a hidden field to capture the total percentages entered.  The alert does not work.  

The value error does appear for the field after it is clicked on, but I need something that will detect the value of this field on a change not just a click or blur.  

 

//Make sure percent does not exceed 100!
$( document ).ready(function() {
  
  $(document).change('.percent input, .totalPer input, .Submit', percen);
  function percenTest() {
    
    
    var tPercen = $('.totalPer input').val();
    alert('Percentage is currently: ', tPercen);
    
    if (tPercen > 100) {
       alert('Percentages can not be greater than 100!');
     }
    
    else{
       alert('Percentage equals: ', tPercen);
     }
  });
});

 

0 0

Replies

replied on February 25, 2018

Hi Ramika,

Can you check if there is js error with your code?

I got this error with your code: "Uncaught ReferenceError: percen is not defined"

And after changing "percen" to "percenTest", there is another error that the ")" should not be added on line 18.

1 0
replied on February 26, 2018

Thanks for pointing  that out.  I made corrections and now it runs but doesn't close.  

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

Sign in to reply to this post.