Hi I need to validate phone number in these formats +1-541-754-3010 , (123) 986-5470 and 123-569-8740 I have given following regex
validates :phone, format: { with: /\A\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}\z/,
message: I18n.t('global.errors.phone_format')}
It working for (123) 986-5470 and 123-569-8740 but not for +1-541-754-3010. Please guide me how to solve this.Thanks in advance
Aucun commentaire:
Enregistrer un commentaire