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/

p1.PNG
When a user types in /> inside the text area, they get the message "Sorry that input is invalid"

tc1_FSGT_Message1.PNG
When a user types in </ inside the text area, they get the message "Sorry that input is invalid"

tc2_LTFS_Message1.PNG
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.

tc3_EnterKey.PNG
How do I fix my example, so pressing the Enter Key on my board doesn't cause the validation to fail?
LVL 1
maqskywalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SwapnilSoftware ArchitectCommented:
Here you go, use below . is not considering new line, so required to add \n . I also updated the jsfeedle.

/^((?!<\/|\/>)(.|\n))*$/

Thanks,
Netswap.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maqskywalkerAuthor Commented:
thanks. great solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.