Help with a JavaScript code to limit the characters of the phone number

Good morning, could you help me with a JavaScript code to limit the number of characters in the phone number box, to prevent the client from leaving wrong data, I tried the following code but it doesn’t work for me.

	function leo($fields) {
    $fields['data-name=celular'], ['name=celular'], ['maxlength'] = 10;
    return $fields;
1 Like

Here is a proper code:

const MAX_LENGTH = 10; // change 10 to any other number.

This code will only limit the input length to the MAX_LENGTH given, but won’t do any further validation on the number.

We are working on native phone number validation.

1 Like

Any news about the native phone number validation?