maqskywalker
asked on
adding keyboard enter key to regular expression in JavaScript function to validate textarea
Hi experts,
I'm using JavaScript and a regular expression to validate input in a TextArea.
Here is my working fiddle:
https://jsfiddle.net/r2d22k18/jj27pLbm/1/
When a user types in /> inside the text area, they get the message "Sorry that input is invalid"
When a user types in </ inside the text area, they get the message "Sorry that input is invalid"
These two case are correct and validation message should show up. Any other input is valid.
But I noticed when I press the Enter key on my keyboard that is also failing the validation and causing the message "Sorry that input is invalid" to display.
How do I fix my example, so pressing the Enter Key on my board doesn't cause the validation to fail?
I'm using JavaScript and a regular expression to validate input in a TextArea.
Here is my working fiddle:
https://jsfiddle.net/r2d22k18/jj27pLbm/1/
When a user types in /> inside the text area, they get the message "Sorry that input is invalid"
When a user types in </ inside the text area, they get the message "Sorry that input is invalid"
These two case are correct and validation message should show up. Any other input is valid.
But I noticed when I press the Enter key on my keyboard that is also failing the validation and causing the message "Sorry that input is invalid" to display.
How do I fix my example, so pressing the Enter Key on my board doesn't cause the validation to fail?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER