check for white space

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stack
    New Member
    • Sep 2007
    • 40

    check for white space

    Hi,

    Can you please tell me if you see anything wrong in my function? It doesn't return true if the string tested contains spaces.

    [HTML]
    function hasWhiteSpace(s trg) {

    var whiteSpaceExp=/^\s+$/;

    if (whiteSpaceExp. test(strg))
    return true;
    else
    return false;
    }
    [/HTML]

    The string passed is that: document.form1. un.value where form1 is the name of the form and un is the name of the field.

    Thank you
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    the regExp should be:

    [CODE=javascript]var whiteSpaceExp=/\s/g;[/CODE]
    kind regards

    Comment

    • stack
      New Member
      • Sep 2007
      • 40

      #3
      Reg exps drive me crazy. Thanks so much!

      Stack

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        no problem ... post back to the forum anytime you have more questions ;)

        kind regards

        Comment

        Working...