Form submission: clean up formatted contact e-mail
Frequently, when creating a form that accepts e-mail addresses I see a lot of bad data that comes in as a result of the user copying a contact out of the e-mail client (Outlook, Firebird, etc.). I decided it would be helpful to write a basic script that cleans up the most common occurances of this issue.
The 3 common occurances I saw of this issue where:
FName LName (email)
FName LName [email]
FName LName <email>
The code I used to clean up these was:
<input type="text" value="" style="width:300px;" onchange="this.value=this.value.replace(/[^(<[)]*[([<](?=.)/gi,'').replace(/[)>]]/gi,'')" /> <input type="text" value="Something to tab to"/>