I choose to validate from PHP because of a couple things.
1. It's more secure because nobody can see my PHP code, but they can
see my jQuery code.
2. If the user has JavaScript disabled, or for some other reason the
jQuery is unable to validate the code, it will still be validated.
On the other
I think comparing two strings would be faster than deciding whether a
string begins with another string.
Also, doing one selection would almost always be faster than doing 3,
so I'd say that the first piece of code from the OP would be faster.
It should only require one loop through the DOM tree.
2 matches
Mail list logo