views:

20

answers:

2

I'm trying to replace the characters < and > onblur with a space when someone enters it into my form.

I've got this at the moment

$(".tbAddress").blur(function() 
{ 
    $("<").replaceWith(" ");
    $(">").replaceWith(" ");
}

Any help would be much appreciated

thanks

Jamie

+1  A: 
$(.tbAddress).blur(function(){
    $(this).val($(this).val().replace("<"," "));
    $(this).val($(this).val().replace(">",' "));
});

If your RegEx-Fu is better than mine, you can combine the two lines and pass in a Regular Expression as the first parameter to replace().

Justin Niessner
Thanks! Works a treat
Jamie Taylor
+1  A: 
$(".tbAddress").blur(function() 
{
    this.value = this.value.replace(/[<>]/, ' '); 
}
hluk