Posted By

laxman2021 on 12/07/12


Tagged

a TextField Trimming


Versions (?)

Validating textfield name for spaces using javascript.


 / Published in: PHP
 

Validating textbox using trim(), in javascript.

  1. // trim function
  2. function trim(str)
  3. {
  4. return str.replace(/^\s*|\s*$/g,"");
  5. }
  6. // end trim
  7.  
  8.  
  9.  
  10. if (trim(document.frmPremises.txtpremisescontactname.value) == '')
  11. {
  12. alert("Enter Contact Name.");
  13. document.frmPremises.txtpremisescontactname.focus();
  14. return(false)
  15. }

Report this snippet  

You need to login to post a comment.