Reputation: 60
I have this text area / form:
<div><textarea name="subject" rows="3" cols="60" placeholder="Please Enter Your Subject..." required="true"></textarea></div>
And obviously if the user types into the text area: su/bject Then su\bject is shown.
Is there a HTML way to make sure no '\' or any other characters apart from Aa - Zz are taken from the form?
Thanks in advance
Upvotes: 1
Views: 19
Reputation: 18995
When submitting, you can catch the result without any unwanted chars by doing this:
yourTextArea.value = yourTextArea.value.replace( /[^a-zA-Z]/g , '');
Or if you want to strip them right on key press, then modify your text area like this:
<textarea onkeyup="this.value = this.value.replace( /[^a-zA-Z]/g, '');" name="subject" rows="3" cols="60" placeholder="Please Enter Your Subject..." required="true"></textarea>
Upvotes: 1