let phoneNumber = $('#order-phone').val()
if (phoneNumber.length == 13) {
parts = phoneNumber.split('-');
if ((parts[0] == '010') && ((parts[1] >= '0000') && (parts[1] <= '9999')) && ((parts[2] >= '0000') && (parts[2] <= '9999'))) {
alert('Finished');
} else {
alert('Put your number like "010-OOOO-OOOO"');
}
} else {
alert('Put your number like "010-OOOO-OOOO"')
}
The situation is like.. The user inputs his phone number as string and then I check the validation for the phone number the user gave to me. 'PhoneNumber' above is string type and I don't know how can I do perfect validate check for the strings that is phone number with 13 characters including numeric characters and hyphen.
https://stackoverflow.com/questions/18375929/validate-phone-number-using-javascript – berkobienb Oct 22 '20 at 17:13