0

I have phone area textbox and i want to test it against values like 1111111 or 9999999.

I want at least 1 character to be different in this text area(it is exactly 7 characters long)

How can i do this in its shortest way?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by ShawnCplus
0

You should still make your checks for length before this but this will check for numbers like 1111111 and 999999

var phone_number = "9999999";
if (!/^(\d)\1{6}$/.test(phone_number)) {
  alert('Good phone number');
} else {
  alert('Bad phone number');
}

Edited by ShawnCplus: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.