Pages

Search This Blog

Tuesday, 7 January 2014

jQuery to trim text

I spent hours and hours to fix a small problem. It is because the way I used the trim function is wrong and it didn't throw any error messages and it was working on few cases. later I found the correct way of trimming spaces in a text using jQuery.

Wrong Way

var customerNo = $("#<%=lblCustomerNo.ClientID%>").text();
customerNo = customerNo.trim();

Right Method

var customerNo = $("#<%=lblCustomerNo.ClientID%>").text();
customerNo = $.trim(customerNo);



 

No comments:

Post a Comment