Code Snippets

  

JavaScript Source Code


Welcome to Dream.In.Code
Become an Expert!

Join 149,621 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,930 people online right now. Registration is fast and FREE... Join Now!





Check For White Space

Function checks for white space from a form field.

Submitted By: skyhawk133
Actions:
Rating:
Views: 16,824

Language: JavaScript

Last Modified: February 28, 2005
Instructions: Call using hasWhiteSpace(form.field.value);

Returns boolean.

Snippet


  1. function hasWhiteSpace(s)
  2. {
  3.  
  4.      reWhiteSpace = new RegExp(/^\s+$/);
  5.  
  6.      // Check for white space
  7.      if (reWhiteSpace.test(s)) {
  8.           alert("Please Check Your Fields For Spaces");
  9.           return false;
  10.      }
  11. return true;
  12. }

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month