2016-11-09 11:10:51 +08:00
function validateForm ( form ) {
2017-05-19 01:50:56 +08:00
var errors = new Array ( ) ;
2016-11-09 11:10:51 +08:00
2017-05-19 01:50:56 +08:00
// If "Can Move" is enabled, then the end user must also select at least one of the other check boxes (excluding Can Move Diagonally)
if ( form . elements [ 'newControl[CanMove]' ] . checked ) {
if ( ! ( form . elements [ 'newControl[CanMoveCon]' ] . checked || form . elements [ 'newControl[CanMoveRel]' ] . checked || form . elements [ 'newControl[CanMoveAbs]' ] . checked || form . elements [ 'newControl[CanMoveMap]' ] . checked ) ) {
errors [ errors . length ] = "In addition to \"Can Move\", you also must select at least one of: \"Can Move Mapped\", \"Can Move Absolute\", \"Can Move Relative\", or \"Can Move Continuous\"" ;
}
} else {
2016-11-09 11:10:51 +08:00
// Now lets check for the opposite condition. If any of the boxes below Can Move are checked, but Can Move is not checked then signal an error
2017-05-19 01:50:56 +08:00
if ( form . elements [ 'newControl[CanMoveCon]' ] . checked || form . elements [ 'newControl[CanMoveRel]' ] . checked || form . elements [ 'newControl[CanMoveAbs]' ] . checked || form . elements [ 'newControl[CanMoveMap]' ] . checked || form . elements [ 'newControl[CanMoveDiag]' ] . checked ) {
errors [ errors . length ] = "\"Can Move\" must also be selected if any one of the movement types are sleceted" ;
2016-11-09 11:10:51 +08:00
}
2017-05-19 01:50:56 +08:00
}
2016-11-09 11:10:51 +08:00
2017-05-19 01:50:56 +08:00
if ( errors . length ) {
alert ( errors . join ( "\n" ) ) ;
2019-01-19 23:32:40 +08:00
return ( false ) ;
2017-05-19 01:50:56 +08:00
}
2019-01-19 23:32:40 +08:00
return ( true ) ;
2016-11-09 11:10:51 +08:00
}