jsp - Issue with the single quote with passing a string to the javascript function -


i'm using custom tag title of field template. in case, there's field "customeremailtitle" has string "riot team's email". i'm passing within javascript function checkemailaddress (as seen below):

<input onblur="checkemailaddress(this, 'the input invalid <getname:getfield fieldkey="customeremailtitle"/> address')" /> 

but single quote in riot team's email seems throwing page off , won't process javascript properly. tried escaping single quotes , double quotes in input tag nothing seems working. has better idea how handle this?

it may helpful you. can set data/string on data attribute of input element.

<html> <body> <input data-message="'the input invalid <getname:getfield fieldkey='customeremailtitle'/> address')" onblur="checkemailaddress(this)" type="text" />  </body>  <script>     function checkemailaddress(elm){         alert(elm.dataset['message']);     } </script> </body> </html> 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -