How to have form automatically add dashes

Background:

I have created a form for persons to enter their phone number. I would like the form to automatically add dashes (-) between the first three number and second three numbers. i.e. 123-456-7890.

Here is my code but it doesn’t seem to work.

[php]


[/php]

Any help is greatly appreciated!

You have a typo here:

onBlur="addDahes(this.value)"

Also, the function should not be looking for this.value since this.value is passed as f

For example:

if(f=='')
	f='Phone:'
else
	f = f.slice(0,3)+"-"+f.slice(3,6)+"-"+f.slice(6,10);
}

I have a function that i downloaded from a website that works perfect, if you want it let me know.

Wilson 382 thank you for all your help!! Very much appreciated!!

Sponsor our Newsletter | Privacy Policy | Terms of Service