Created
May 7, 2018 06:04
-
-
Save jerinisready/e38107f54ec958c7d5c76cc31fbe00c4 to your computer and use it in GitHub Desktop.
trim any spaces at the start of the text box and trim any spaces at the end of the textbox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function trim(el){ | |
el.value = el.value. | |
replace (/(^\s*)|(\s*$)/gi, ""). // removes leading and trailing spaces | |
replace (/[ ]{2,}/gi," "). // replaces multiple spaces with one space | |
replace (/\n +/,"\n"); // Removes spaces after newlines | |
return true; | |
} | |
</script> | |
<input type="text" name="email" id="_email" pattern=".{3,}@.{3,}\..{2,5}" onchange="return trim(this)" required="required" class="input input_email" placeholder="Email Address *"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment