validation - jQuery to trim() a text input field's value attribute? -



validation - jQuery to trim() a text input field's value attribute? -

in jqeury, i'm able bind paste event validate form field, method within function apparently wrong. i'm not getting alert @ all.

i want trim text that's input , homecoming value of form input text field #adsense_client_id.

$("#adsense_client_id").bind('paste', function(e) { $(this).attr('value') = $.trim(this).val(); alert($(this).val()); //why no alert? });

the $.trim function needs variable/string within it, since did not wrap $(this).val() $.trim in order work.

as need timeout paste caught, this:

$("#adsense_client_id").bind('paste', function(e) { var clientid = $(this); settimeout(function(){ clientid.val($.trim(clientid.val())); alert(clientid.val()); }); });

demo.

jquery validation

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -