1
0
Fork 0

Checks fields when download button is pressed and submits the form

This commit is contained in:
7u83 2020-02-25 08:53:52 +00:00
parent 7e252ae4e5
commit 0a3a0f68be
2 changed files with 50 additions and 7 deletions

View File

@ -40,7 +40,7 @@
</div>
<div class="is-col">
<input required type="input"
size="32" id="projekt" name="project"
size="32" id="projectid" name="project"
placeholder="Projekt-ID*" />
</div>
</div>
@ -48,7 +48,7 @@
<div class="is-row">
<div class="is-col">
<input required type="input" size="32"
` name="realname" placeholder="Realname*" />
` id="realname" name="realname" placeholder="Realname*" />
</div>
<div class="is-col">
</div>
@ -224,14 +224,15 @@
</div>
<button onclick="addTableRow();"
class="button is-green">Antrag elektronisch versenden</button>
<button type="button" onclick="alert('hello');"
<button type="button" onclick="downloadDocument();"
class="button is-orange">Herunterladen</button>
</div>
</div>
<!-- <input type="submit" style="display:none" name="submitButton" /> -->
<!-- <input type="submit" style="display:none" name="submitButton" /> -->
</form>

View File

@ -29,7 +29,7 @@ function deleteTableRow(rowId){
var target = document.getElementById("upload-target"+rowId);
// this.message = app.message;
var children = target.children;
// var children = target.children;
// delete all uploaded elements
/* for (var i = 0; i < children.length; i++) {
@ -56,6 +56,17 @@ function deleteTableRow(rowId){
}
function countRows(){
var ctr=0;
for (i=0; i<currentRowId; i++){
var element = document.getElementById("trow"+i);
if (element)
ctr++
}
return ctr;
}
function showAlert(text) {
$K.app.message.show( { message: `${text}`, position: 'centered', type: 'is-error' });
@ -210,7 +221,7 @@ $K.add('module', 'kaform', {
opened: function(sender)
{
console.log('Tab box is ',sender.getActiveBox());
this.message.show({ message: 'My message' });
// this.message.show({ message: 'My message' });
}
}
},
@ -239,7 +250,38 @@ $K.ajax.get({
setUploadField();
function check_field(fieldid,message){
var f = document.getElementById(fieldid).value;
if (! f.trim().length ) {
document.getElementById(fieldid).focus();
showAlert(message)
return false;
}
return true;
}
// add on table row
//addTableRow();
//
//
//
function downloadDocument()
{
if (!check_field("nickname", "Bitte gib deinen Nicknamen an!"))
return;
if (!check_field("realname", "Bitte gib deinen Realnamen an!"))
return;
if (!check_field("email", "Bitte gib deinen E-Mail-Adresse an!"))
return;
if (!check_field("projectid", "Bitte gib idie Projekt-ID an!"))
return;
if (countRows()==0){
document.getElementById("a_type").focus();
showAlert("Bitte f&uuml;ge mind. eine Auslage hinzu!");
return;
}
document.getElementById("theform").submit();
}