Link to home
Create AccountLog in
Avatar of deharvy
deharvy

asked on

Check If Form Element Exist in Page

Here is my form:

<form name="FormXX" method="post" action="default.htm">
<input id="idBoxOne" name="bxOne" type="text">
</form>

I know how to get the value of an input button.

     var text = document.FormXX.bxOne.value;
   
How do I write an if statement to check if the form value of bxOne exist or not?
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
deharvy,

By the way .. that is Javascript, which is what you were using in the code you had for the example.  You posted this in the PHP zone though so if you need this on the server in PHP then use ...

if (isset($_POST["bxOne"])) {
    // the browser sent something for this field
} else {
   // nothing was in this field
}

Let me know if you have a question.

b0lsc0tt
I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol