开发者

jQuery to validate input field for empty characters at end of string?

My WordPress theme has a slot for the site owner to input their Adsense Client ID. Apparently its very easy for the user to accidentally grab some empty spaces at the end of the ID during the copy/paste routine.

When this happens, the ads don't work since the Pub ID looks something like this in markup:

google_ad_client = "pub-1234567890987654";

I'd l开发者_如何学编程ike to use jQuery to check this value, once its been entered, for empty spaces at the end and alert the user.

Does jQuery have a means to do this?


You could just trim it using $.trim()

google_ad_client = $.trim('pub-1234567890987654    ');


Yes:

$.trim(google_ad_client);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜