i have search box , user can put search text it. example: book, 'book', "book". , in js file, variable value search box.
var searchtext= "${searchtext}"; <br/>
this code failed if user put "book" search box.because time,
var searchtext= ""book"".
if change
var searchtext= "${searchtext}"; var searchtext= '${searchtext}';
this code failed if user put 'book' search box. please me, !
you can both replace "
or '
single quote '
. here's example:
var str= '"book"'; str.replace(/["|']+/g, "'");
demo: jsfiddle
Comments
Post a Comment