add form validation

This commit is contained in:
Uwe Steinmann 2021-12-03 09:30:43 +01:00
parent c75a9ef455
commit 2c182e3d09

View File

@ -33,8 +33,22 @@ class SeedDMS_View_ChangePassword extends SeedDMS_Theme_Style {
function js() { /* {{{ */ function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8'); header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
?> ?>
document.form1.newpassword.focus(); document.form1.newpassword.focus();
$(document).ready(function() {
$("#form1").validate({
rules: {
newpasswordrepeat: {
equalTo: "#newpassword"
}
},
messages: {
newpassword: "<?php printMLText("js_no_pwd");?>",
newpasswordrepeat: "<?php printMLText("js_pwd_not_conf");?>",
},
});
});
<?php <?php
} /* }}} */ } /* }}} */
@ -44,12 +58,15 @@ document.form1.newpassword.focus();
$hash = $this->params['hash']; $hash = $this->params['hash'];
$passwordstrength = $this->params['passwordstrength']; $passwordstrength = $this->params['passwordstrength'];
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("change_password"), "login"); $this->htmlStartPage(getMLText("change_password"), "login");
$this->globalBanner(); $this->globalBanner();
$this->contentStart(); $this->contentStart();
$this->pageNavigation(getMLText("change_password")); $this->pageNavigation(getMLText("change_password"));
?> ?>
<form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" name="form1"> <form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" id="form1" name="form1">
<?php echo createHiddenFieldWithKey('changepassword'); ?> <?php echo createHiddenFieldWithKey('changepassword'); ?>
<?php <?php
if ($referuri) { if ($referuri) {
@ -61,7 +78,7 @@ document.form1.newpassword.focus();
$this->contentContainerStart(); $this->contentContainerStart();
$this->formField( $this->formField(
getMLText("password"), getMLText("password"),
'<input class="pwd form-control" type="password" rel="strengthbar" name="newpassword" id="password">' '<input class="pwd form-control" type="password" rel="strengthbar" name="newpassword" id="newpassword" required="required">'
); );
if($passwordstrength > 0) { if($passwordstrength > 0) {
$this->formField( $this->formField(
@ -74,9 +91,10 @@ document.form1.newpassword.focus();
array( array(
'element'=>'input', 'element'=>'input',
'type'=>'password', 'type'=>'password',
'id'=>'passwordrepeat', 'id'=>'newpasswordrepeat',
'name'=>'newpasswordrepeat', 'name'=>'newpasswordrepeat',
'autocomplete'=>'off', 'autocomplete'=>'off',
'required'=>true
) )
); );
$this->contentContainerEnd(); $this->contentContainerEnd();