Lawrence Cooke
Lawrence Cooke

Reputation: 1597

Working with livevalidation.js

I am using livevalidation.js (http://livevalidation.com/) to validate a form.

this mostly works but I am having trouble getting it to do something I need it to do.

I have two fields "how many children" and "age of children"

Basically, I need it to check for presence of answer in "age of children" if "how many children" is filled out.

If they have not filled out "how many children", then it does not matter if "age of children" is filled out.

I know how to check for presence, but I don't know how to check for it ONLY IF the other field is also filled out.

Any help would be greatly appreciated.

Upvotes: 1

Views: 429

Answers (1)

Trevor Arjeski
Trevor Arjeski

Reputation: 2168

if(
numofchildren.Presence( 'children are here', { failureMessage: "Supply come childrens!" } ) == true 
&& ageofchildren.Presence( 'children have ages', { failureMessage: "no children!" } ) == true){

//do work 
} 

Upvotes: 1

Related Questions