Skip to main content

Hi, I would like to build a pattern to validate user input for contact number, the input must be in the format of "0xxxx xxxxx" or "8 xxx-xxxx" ("01234 123456" or" 8 123-1234"). I created below-

^((000-9]{4}ss0-9]{6})|(8ss0-9]{3}--0-9]{4}))$
And this is getting wrong to validate the input. Could you please correct me where I am getting wrong.
 
Regards,
Ram

Dear,

 

According to  "0xxxx xxxxx" or "8 xxx-xxxx" your REGEX should be like this:

 

^((0(0-9]{4}s40-9]{5})|(8s(0-9]{3}-30-9]{4}))$


Hi Mustafa, Thank you for your reply, I tried with the REGEX shared by you but infortunately this is not working, it looks like the same as I posted.

 

Could you/someone plz suggest correct one?

 

Regards,

Ram


Dear,

 

I only edited the dash - 

Can you please show me the values you enter to test the validation?

 

it works well with me,

 

Ex: 05555 55555 or  8 333-4444

 

 

Create you Regex and test it here
 http://www.regexr.com/

 


Hi Mustafa, Thank you again for your reply, I chnaged my regex from your and validated against the same values as your mentioned your last reply, but strange I am moving to validation pass. Moreover I tried to inserted my values but again failed. Please get attached error screenshots, one screenshot id to create custom validation pattern and second is of validation failed.

 

Regards,

Ram


12887iFD6B2060565EB607.jpg
15784i0822227D45D188FD.jpg

Dear, 

 

according to the regex the number second part should have 5 numbers not 6

if you wanna make it 6 numbers change a0-9]{5} to t0-9]{6} 


Reply