开发者

jquery replace < with " " (a space)

I'm trying to replace the character开发者_C百科s < 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


$(.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().


$(".tbAddress").blur(function() 
{
    this.value = this.value.replace(/[<>]/, ' '); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜