Validating textfield name for spaces using javascript.


/ Published in: PHP
Save to your folder(s)

Validating textbox using trim(), in javascript.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.