prevent the end user from slecting an invalid configuration on the PT… (#1676)

* prevent the end user from slecting an invalid configuration on the PTZ control configuraion "Move" tab

* change to console.php should not be in this pr
pull/1681/head
Andrew Bauer 2016-11-08 21:10:51 -06:00 committed by Isaac Connor
parent 8c41781a9f
commit 9f43825b92
2 changed files with 25 additions and 1 deletions

View File

@ -183,7 +183,7 @@ foreach ( $tabs as $name=>$value )
?>
</ul>
<div class="clear"></div>
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm( this )">
<input type="hidden" name="view" value="<?php echo $view ?>"/>
<input type="hidden" name="tab" value="<?php echo $tab ?>"/>
<input type="hidden" name="action" value="controlcap"/>

View File

@ -0,0 +1,24 @@
function validateForm( form ) {
var errors = new Array();
// 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 {
// 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
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";
}
}
if ( errors.length ) {
alert( errors.join( "\n" ) );
return( false );
}
return( true );
}