javascript - PHP/jQuery to submit/save input with all special characters value -
example..
html :
<input type="hidden" value="">
php :
<input type="hidden" value="<?php echo $value;?>">
jquery :
$("input:hidden").val(text);
if text
(js variable) free text, html special characters allowed (like single quote / double quote) , save input:hidden
(so submit php)
what correctly way ?
may use
echo htmlentities($value);
... in php
or replace quotes in jquery .val(text.replace(/'/g,"’"))
or ?
ps : please think when set value input save value jquery too.
converting htmlentities should work fine.
you can use strip_tags if want remove html tags :
note: not stop xss attacks
Comments
Post a Comment