January 10, 2012

Trim Text boxes using java script

Why we need TextBox.Text.Trim() in server side code, We can achieve this from client side itself.
Just create a function like below and call it from "OnClientClick" of Save button, That's it.

   1:  function fnTrimTextBoxes()
   2:  {
   3:     document.getElementById('textBoxName').value = document.getElementById('textBoxName').value.replace(/^\s+|\s+$/g, "");
   4:  }

No comments:

Post a Comment