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
Post a Comment