Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

Check for spaces in text field


test a user input to see if it is blank, or has spaces within it

function BlankOrHasSpace (myStsring) {
    var result = true
    if (myString ! = "" ) {
        for (x = 0; x < myString.length; x ++ ) {
            var char = myString.charAt (x)
            if ( char != " " ) {
               result = false
                break ;
            }
        }
    }
}