So I’m sure this is probably an easy Javascript code (unfortunately I really don’t know Javascript), but I’m trying to remove special characters from a template variable’s output. In this case, I want to remove any special characters the end user may input. In this case, when someone enters information into "Title" field in the document, I want the output (in this case, the [*pagetitle*] T.V. as seen below) to remove the special characters (i.e. ’, #, *, ", etc.). Here’s my code below (see it live at:
http://www.cherubscottage.com/131.html):
<form action="https://cherubscottage.foxycart.com/cart" class="foxycart" method="post">
<input type="hidden" name="name" value="[*pagetitle*]" />
<input type="hidden" name="price" value="[*price*]" />
<input type="hidden" name="storeid" value="[*storeid*]" />
<input type="hidden" name="weight" value="[*weight*]" />
<input id="shoppingcartlogo" type="image" src="assets/templates/cherubscottage/layout/add-to-cart.gif" alt="Add to Basket" />
</form>
I was playing with some Javascript, trying to modify it (but again, I know really nothing of Javascript), but here’s the basic idea:
function filterNum(str) {
re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
// remove special characters like "$" and "," etc...
return str.replace(re, "");
}
Is there a way in MODx to remove special characters from T.V.’s output? Or do I just need Javascript (and if so, any recommendations for that coding?)?
Thanks!