Validation javascript field with Split

Asked

Viewed 51 times

0

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

I’m doing so, but I need him to take the amount and not the values:

 var str = $("#FormaCalculosVencimentos").val();
    var arr = str.split(",");
    alert(arr);
  • 2

    But if arr is a array, don’t just take arr.length?

  • That’s right rs, it worked right.

1 answer

1


The split function will create an array. After, 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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.