mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 13:11:31 +00:00
add more field validation
This commit is contained in:
parent
c8a689cf60
commit
96a4db05bf
|
@ -74,6 +74,37 @@ $(document).ready(function() {
|
||||||
$('#new-file').click(function(event) {
|
$('#new-file').click(function(event) {
|
||||||
$("#upload-file").clone().appendTo("#upload-files").removeAttr("id").children('div').children('input').val('');
|
$("#upload-file").clone().appendTo("#upload-files").removeAttr("id").children('div').children('input').val('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var validator = $("#form1").bind("invalid-form.validate", function() {
|
||||||
|
noty({
|
||||||
|
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}).validate({
|
||||||
|
rules: {
|
||||||
|
"_userfile[]": {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
"_userfile[]": "<?php printMLText("js_no_name");?>",
|
||||||
|
name: "<?php printMLText("js_no_name");?>",
|
||||||
|
comment: "<?php printMLText("js_no_comment");?>",
|
||||||
|
keywords: "<?php printMLText("js_no_keywords");?>"
|
||||||
|
},
|
||||||
|
errorPlacement: function( error, element ) {
|
||||||
|
if ( element.is( ":file" ) ) {
|
||||||
|
error.appendTo( element.parent().parent().parent());
|
||||||
|
console.log(element);
|
||||||
|
} else {
|
||||||
|
error.appendTo( element.parent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
$this->printKeywordChooserJs("form1");
|
$this->printKeywordChooserJs("form1");
|
||||||
|
@ -98,6 +129,8 @@ $(document).ready(function() {
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
$folderid = $folder->getId();
|
$folderid = $folder->getId();
|
||||||
|
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -131,7 +164,7 @@ $(document).ready(function() {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("comment");?>:</td>
|
<td><?php printMLText("comment");?>:</td>
|
||||||
<td><textarea name="comment" rows="3" cols="80"></textarea></td>
|
<td><textarea name="comment" rows="3" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("keywords");?>:</td>
|
<td><?php printMLText("keywords");?>:</td>
|
||||||
|
|
|
@ -61,10 +61,26 @@ function checkForm()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
$('body').on('submit', '#form1', function(ev){
|
/* $('body').on('submit', '#form1', function(ev){
|
||||||
if(checkForm()) return;
|
if(checkForm()) return;
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
var validator = $("#form1").bind("invalid-form.validate", function() {
|
||||||
|
noty({
|
||||||
|
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}).validate({
|
||||||
|
messages: {
|
||||||
|
name: "<?php printMLText("js_no_name");?>",
|
||||||
|
comment: "<?php printMLText("js_no_comment");?>"
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -76,6 +92,8 @@ $(document).ready( function() {
|
||||||
$strictformcheck = $this->params['strictformcheck'];
|
$strictformcheck = $this->params['strictformcheck'];
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
|
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -91,11 +109,11 @@ $(document).ready( function() {
|
||||||
<table class="table-condensed">
|
<table class="table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="inputDescription"><?php printMLText("name");?>:</td>
|
<td class="inputDescription"><?php printMLText("name");?>:</td>
|
||||||
<td><input type="text" name="name" size="60"></td>
|
<td><input type="text" name="name" size="60" required></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="inputDescription"><?php printMLText("comment");?>:</td>
|
<td class="inputDescription"><?php printMLText("comment");?>:</td>
|
||||||
<td><textarea name="comment" rows="4" cols="80"></textarea></td>
|
<td><textarea name="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="inputDescription"><?php printMLText("sequence");?>:</td>
|
<td class="inputDescription"><?php printMLText("sequence");?>:</td>
|
||||||
|
|
|
@ -1021,9 +1021,10 @@ function folderSelected<?php echo $formName ?>(id, name) {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function printKeywordChooserHtml($formName, $keywords='', $fieldname='keywords') { /* {{{ */
|
function printKeywordChooserHtml($formName, $keywords='', $fieldname='keywords') { /* {{{ */
|
||||||
|
$strictformcheck = $this->params['strictformcheck'];
|
||||||
?>
|
?>
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
<input type="text" name="<?php echo $fieldname; ?>" value="<?php print htmlspecialchars($keywords);?>" />
|
<input type="text" name="<?php echo $fieldname; ?>" id="<?php echo $fieldname; ?>" value="<?php print htmlspecialchars($keywords);?>"<?php echo $strictformcheck ? ' required' : ''; ?> />
|
||||||
<a data-target="#keywordChooser" role="button" class="btn" data-toggle="modal" href="out.KeywordChooser.php?target=<?php echo $formName; ?>"><?php printMLText("keywords");?>…</a>
|
<a data-target="#keywordChooser" role="button" class="btn" data-toggle="modal" href="out.KeywordChooser.php?target=<?php echo $formName; ?>"><?php printMLText("keywords");?>…</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal hide" id="keywordChooser" tabindex="-1" role="dialog" aria-labelledby="keywordChooserLabel" aria-hidden="true">
|
<div class="modal hide" id="keywordChooser" tabindex="-1" role="dialog" aria-labelledby="keywordChooserLabel" aria-hidden="true">
|
||||||
|
@ -1069,7 +1070,7 @@ $('#acceptkeywords').click(function(ev) {
|
||||||
break;
|
break;
|
||||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||||
?>
|
?>
|
||||||
<span class="input-append date datepicker" style="display: inline;" data-date="<?php echo date('Y-m-d'); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
|
<span class="input-append date datepicker" style="_display: inline;" data-date="<?php echo date('Y-m-d'); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
|
||||||
<input class="span4" size="16" name="<?php echo $fieldname ?>[<?php echo $attrdef->getId() ?>]" type="text" value="<?php if($objvalue) echo $objvalue; else echo "" /*date('Y-m-d')*/; ?>">
|
<input class="span4" size="16" name="<?php echo $fieldname ?>[<?php echo $attrdef->getId() ?>]" type="text" value="<?php if($objvalue) echo $objvalue; else echo "" /*date('Y-m-d')*/; ?>">
|
||||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -1084,7 +1085,7 @@ $('#acceptkeywords').click(function(ev) {
|
||||||
} else {
|
} else {
|
||||||
echo "\"";
|
echo "\"";
|
||||||
}
|
}
|
||||||
echo ">";
|
echo "".($attrdef->getMinValues() > 0 ? ' required' : '').">";
|
||||||
if(!$attrdef->getMultipleValues()) {
|
if(!$attrdef->getMultipleValues()) {
|
||||||
echo "<option value=\"\"></option>";
|
echo "<option value=\"\"></option>";
|
||||||
}
|
}
|
||||||
|
@ -1101,9 +1102,9 @@ $('#acceptkeywords').click(function(ev) {
|
||||||
echo "</select>";
|
echo "</select>";
|
||||||
} else {
|
} else {
|
||||||
if (strlen($objvalue) > 80) {
|
if (strlen($objvalue) > 80) {
|
||||||
echo '<textarea class="input-xxlarge" name="'.$fieldname.'['.$attrdef->getId().']">'.htmlspecialchars($objvalue).'</textarea>';
|
echo '<textarea class="input-xxlarge" name="'.$fieldname.'['.$attrdef->getId().']"'.($attrdef->getMinValues() > 0 ? ' required' : '').'>'.htmlspecialchars($objvalue).'</textarea>';
|
||||||
} else {
|
} else {
|
||||||
echo "<input type=\"text\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"".htmlspecialchars($objvalue)."\" />";
|
echo "<input type=\"text\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"".htmlspecialchars($objvalue)."\"".($attrdef->getMinValues() > 0 ? ' required' : '')." />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -65,10 +65,28 @@ function checkForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
|
/*
|
||||||
$('body').on('submit', '#form1', function(ev){
|
$('body').on('submit', '#form1', function(ev){
|
||||||
if(checkForm()) return;
|
if(checkForm()) return;
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
var validator = $("#form1").bind("invalid-form.validate", function() {
|
||||||
|
noty({
|
||||||
|
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}).validate({
|
||||||
|
messages: {
|
||||||
|
name: "<?php printMLText("js_no_name");?>",
|
||||||
|
comment: "<?php printMLText("js_no_comment");?>",
|
||||||
|
keywords: "<?php printMLText("js_no_keywords");?>"
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -82,6 +100,8 @@ $(document).ready( function() {
|
||||||
$strictformcheck = $this->params['strictformcheck'];
|
$strictformcheck = $this->params['strictformcheck'];
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
|
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -100,11 +120,11 @@ $(document).ready( function() {
|
||||||
<table cellpadding="3">
|
<table cellpadding="3">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="inputDescription"><?php printMLText("name");?>:</td>
|
<td class="inputDescription"><?php printMLText("name");?>:</td>
|
||||||
<td><input type="text" name="name" id="name" value="<?php print htmlspecialchars($document->getName());?>" size="60"></td>
|
<td><input type="text" name="name" id="name" value="<?php print htmlspecialchars($document->getName());?>" size="60" required></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" class="inputDescription"><?php printMLText("comment");?>:</td>
|
<td valign="top" class="inputDescription"><?php printMLText("comment");?>:</td>
|
||||||
<td><textarea name="comment" id="comment" rows="4" cols="80"><?php print htmlspecialchars($document->getComment());?></textarea></td>
|
<td><textarea name="comment" id="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>><?php print htmlspecialchars($document->getComment());?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" class="inputDescription"><?php printMLText("keywords");?>:</td>
|
<td valign="top" class="inputDescription"><?php printMLText("keywords");?>:</td>
|
||||||
|
|
|
@ -61,10 +61,27 @@ function checkForm()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
/*
|
||||||
$('body').on('submit', '#form1', function(ev){
|
$('body').on('submit', '#form1', function(ev){
|
||||||
if(checkForm()) return;
|
if(checkForm()) return;
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
var validator = $("#form1").bind("invalid-form.validate", function() {
|
||||||
|
noty({
|
||||||
|
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}).validate({
|
||||||
|
messages: {
|
||||||
|
name: "<?php printMLText("js_no_name");?>",
|
||||||
|
comment: "<?php printMLText("js_no_comment");?>"
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -78,6 +95,8 @@ $(document).ready(function() {
|
||||||
$strictformcheck = $this->params['strictformcheck'];
|
$strictformcheck = $this->params['strictformcheck'];
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
|
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -91,11 +110,11 @@ $(document).ready(function() {
|
||||||
<table class="table-condensed">
|
<table class="table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("name");?>:</td>
|
<td><?php printMLText("name");?>:</td>
|
||||||
<td><input type="text" name="name" value="<?php print htmlspecialchars($folder->getName());?>" size="60"></td>
|
<td><input type="text" name="name" value="<?php print htmlspecialchars($folder->getName());?>" size="60" required></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("comment");?>:</td>
|
<td><?php printMLText("comment");?>:</td>
|
||||||
<td><textarea name="comment" rows="4" cols="80"><?php print htmlspecialchars($folder->getComment());?></textarea></td>
|
<td><textarea name="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>><?php print htmlspecialchars($folder->getComment());?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$parent = ($folder->getID() == $rootfolderid) ? false : $folder->getParent();
|
$parent = ($folder->getID() == $rootfolderid) ? false : $folder->getParent();
|
||||||
|
|
|
@ -70,10 +70,26 @@ function checkForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
|
/*
|
||||||
$('body').on('submit', '#form1', function(ev){
|
$('body').on('submit', '#form1', function(ev){
|
||||||
if(checkForm()) return;
|
if(checkForm()) return;
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
var validator = $("#form1").bind("invalid-form.validate", function() {
|
||||||
|
noty({
|
||||||
|
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||||
|
type: 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}).validate({
|
||||||
|
messages: {
|
||||||
|
comment: "<?php printMLText("js_no_comment");?>",
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -93,6 +109,8 @@ $(document).ready( function() {
|
||||||
$presetexpiration = $this->params['presetexpiration'];
|
$presetexpiration = $this->params['presetexpiration'];
|
||||||
$documentid = $document->getId();
|
$documentid = $document->getId();
|
||||||
|
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
$this->contentStart();
|
$this->contentStart();
|
||||||
|
@ -163,7 +181,7 @@ $(document).ready( function() {
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("comment");?>:</td>
|
<td><?php printMLText("comment");?>:</td>
|
||||||
<td class="standardText">
|
<td class="standardText">
|
||||||
<textarea name="comment" rows="4" cols="80"></textarea>
|
<textarea name="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue
Block a user