问题描述:

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.

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

//do work 
} 
相关阅读:
Top