If you’re validating an email address a space at the beginning and/or end of the input could cause the email to fail validation even though it looks okay to the user; this can happen if the email is pasted in. This simple bit of JavaScript will prevent that happening.
<input type="text" oninput="this.value = this.value.trim();" value="" />
