I found this code on some website and I don't know how to validate phone number in real time with javascript.The number should appear as such:(123)-456-7890 and the hyphens,brackets and spaces should be handled by the script and not after all the 10 digits are typed in.
I'm using this regular expression but I don't know how to validate it in real time: /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s.]{0,1}[0-9]{3}[-\s.]{0,1}[0-9]{4}$/
How can I do this phone validation in real time with javascript so that no user will be allowed to add brackets/spaces/hyphens,that should be handled by script?