Link to home
Start Free TrialLog in
Avatar of earwig75
earwig75

asked on

Assistance with JavaScript/jQuery validation

I have a button called "letsgo". When it is clicked I want to make sure that both a text area (Notes) and a a text field (theperson) are populated. Could someone help me with the "if" part of my validation below? Thank you.

	window.onload = function() {
    document.getElementById("letsgo").onclick = function() {
        var TextArea = document.getElementsByName("Notes")[0];
        var TextField = document.getElementsByName("theperson")[0];
        if ..................
        {
            alert("Please enter a Person and Notes."); 
            return false;
        }
        return true;
    }
}

Open in new window

SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of earwig75
earwig75

ASKER

I ended up using the below. I needed both required and 1 text area and 1 text field.

Thank you for the assistance.

if (TextArea.value.length==0 || TextArea.value.length==0)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be closed as follows:

Accepted answer: 0 points for earwig75's comment #a40204804
Assisted answer: 500 points for Randy Poole's comment #a40204765

for the following reason:

The assistance had what I believe was a typo. I also needed both to be required.
ahh ok, but you are comparing the same value twice :)