Validation javascript field with Split

0

I need to do a javascript validation, which picks up how many are filled, the mask is this way: 000,000,000,000 etc. in case it should get 4, because it is the sequence of 4, each 000 one account, the user will fill type: 030,050,060 etc. to compare with the number of payments.

I'm doing this, however I need it to take the quantity, not the values:

 var str = $("#FormaCalculosVencimentos").val();
    var arr = str.split(",");
    alert(arr);
    
asked by anonymous 06.11.2018 / 19:28

1 answer

1

The split function will create an array. Afterwards, you can use the length function to get the size of your arr variable.

var str = $("#FormaCalculosVencimentos").val();
var arr = str.split(",");
alert(arr.length);
    
08.11.2018 / 19:07