I have an email app which needs to let users enter multiple email addresses into a text field, then separate out the addresses using Javascript for validation, and also separate the addresses using PHP when the form is submitted.
The script needs to support addresses in the form of
John Doe <jdoe@example.com>; Smith, Jane <jsmith@example.com>; johnd@example.com
The issue is that there's really no dependable delimiter I can use between addresses. Separating them with a semicolon will work a lot of the time, but there's no guarantee that a semicolon won't be used in the name portion. Using commas won't work since names often appear as "Smith, Jane" and the code will interpret the comma embedded in the name as a delimiter between addresses.
I guess I can improve the odds by only allowing the address portion in the text fields:
jdoe@example.com, jsmith@example.com, johnd@example.com
but under certain conditions, email addresses can contain pretty much any character, i.e.:
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
so there still doesn't seem to be an absolutely certain way to delimit multiple addresses in text fields.
Is there another/better way to let users enter multiple addresses into an HTML form and still keep the addresses separate?
The script needs to support addresses in the form of
John Doe <jdoe@example.com>; Smith, Jane <jsmith@example.com>; johnd@example.com
The issue is that there's really no dependable delimiter I can use between addresses. Separating them with a semicolon will work a lot of the time, but there's no guarantee that a semicolon won't be used in the name portion. Using commas won't work since names often appear as "Smith, Jane" and the code will interpret the comma embedded in the name as a delimiter between addresses.
I guess I can improve the odds by only allowing the address portion in the text fields:
jdoe@example.com, jsmith@example.com, johnd@example.com
but under certain conditions, email addresses can contain pretty much any character, i.e.:
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
so there still doesn't seem to be an absolutely certain way to delimit multiple addresses in text fields.
Is there another/better way to let users enter multiple addresses into an HTML form and still keep the addresses separate?