Is their a way i can check for a text field being null. For instance its ok if its set to zero, but if theirs nothing typed into that field then i would like to find out. I tried just doin an "IF" on the text field name, but that doesnt work it a zero was typed into that field. Only numeric values are being entered into these text fields.

Thanks in advance.

Ira

    $name of text field = the name of our textarea

    if(empty($name of text field ))
    {
    //is empty do some stuff
    }
    else
    {
    theres some stuff maybe a space
    }

    if you also wanna process if theres only a blank(space pressed) as well

    do this

    if(empty($name of text field ) || $name of text feild = " ")
    {
    //is empty do some stuff
    }
    else
    {
    theres some stuff maybe a space
    }

    Hope this comes to some help

      Thanks for the response. That didnt work but i found a work around. I guess this is somewhat of a quirk with php but if you test for $name == NULL it doesnt test for zero. Which is what i need.

        If the field is completely empty, it won't be part of the submitted request, and hence you can test to see if it isset() or not. If it is, you can check further to make sure it is_numeric() (which you'd have to do anyway of course, in case the user typed in "NotANumber!").

          10 days later

          test for $name == NULL it doesnt test for zero. Which is what i need. [/B]

          How about using a regular expression?

          if (!ereg("^[0-9]+$", $your_variable)) {
              print("Input error...");
          }

            Try strlen()

            if(strlen($var)<1){
            echo "BAD";
            }

              Write a Reply...