Does jQuery have an equivalent of PHP’s str_replace? I am needing to replace spaces in a text box with hyphens.
I googled and looked in the forum search but wasn’t coming up with a good answer.
Does jQuery have an equivalent of PHP’s str_replace? I am needing to replace spaces in a text box with hyphens.
I googled and looked in the forum search but wasn’t coming up with a good answer.
To add to the above, you don’t even need a regular expression:
str.replace(' ', '-');
Also please note that that isn’t jQuery, that’s JavaScript. jQuery is not a language. If you have a text box, you’ll probably have to do something like this with jQuery:
var textarea = $('#the_textarea');
var txt = textarea.val();
textarea.val(txt.replace(' ', '-'));