I\'m trying to do a string replace in a textarea after the user has entered their content and nothing I\'ve tried is working. Any help would be greatly appreciated. This is wher
Try this,
$("#field_id_29").change(function(){
var text = $(this).val();
var regexp = /www-source/gi;
if ( text.match(regexp) ){
text = text.replace(/www-source/g,"www");
return $(this).val(text);
}
return false;
});
When the field changes we grab the value, compare if against a regular expression and if we have a match we replace the text and we are done, otherwise we just return.