For example, if the field value was "John Wayne" I would want it to be replaced with "John_Wayne"
I'm thinking I can accomplish this through jQuery, basic idea is below:
$('#searchform').submit(function() {
//take current field value
//replace characters in field
//replace field with new value
});
Any help is appreciated.
You could use the overload of val
that takes a function:
$("input:text").val(function (i, value) {
/* Return the new value here. "value" is the old value of the input: */
return value.replace(/\s+/g, "_");
});
(You'll probably want your selector to be more specific than input:text
)
Example: http://jsfiddle.net/nTXse/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With