iPad form submittals are breaking my CRM code - need to stop carriage returns


We have a text area field in a form that some people fill out with their iPads. Unfortunately, if these users hit the Return key on their iPad keyboard when in this textarea field, it's saving a value (can't tell what it is - MSSQL just shows a linebreak in the db table) but this is breaking a javascript calendar grid we are using.

Bottom line, we would like to have the enter key, if press, just close the keyboard view and not insert any value into the text area for that keystroke.

Is this possible? Maybe with some kind of blur command that detects that particular keystroke?

Just not sure how to achieve this...


Who is Participating?
GaryConnect With a Mentor Commented:
To submit the form

onkeypress='if(event.keyCode==13){document.forms["form_name"].submit();return false;}'
billium99Author Commented:
Thanks Quizwedge - hmm - I think this may be the opposite of what I'm after though - I'd be fine if the return key submitted the form instead of adding this line break in the textarea field.

Do you know how to do that?
To disable the enter key you can just add this to the textarea

onkeypress="if(event.keyCode==13){return false;}"

To close the keyboard you would need to set focus somewhere else.
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

@GaryC123 Thanks for the heads up. I hadn't seen that before and was trying to post something quickly from my phone. I'll add more explanation or link to a different site in the future.

@billium99 looks like @garyc123 answered but if you need more clarification let us know.
Not sure how this will work in the iphone but to lose focus on the textarea, which should hide the keyboard

onkeypress="if(event.keyCode==13){this.blur();return false;}"

All depends which solution you prefer.
billium99Author Commented:
Thanks Gary - trying today...
billium99Author Commented:
Thanks for the help!
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.

All Courses

From novice to tech pro — start learning today.