forked from tohe/wmdeit_kaform
Checks fields when download button is pressed and submits the form
This commit is contained in:
parent
7e252ae4e5
commit
0a3a0f68be
7
ka.html
7
ka.html
|
@ -40,7 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="is-col">
|
<div class="is-col">
|
||||||
<input required type="input"
|
<input required type="input"
|
||||||
size="32" id="projekt" name="project"
|
size="32" id="projectid" name="project"
|
||||||
placeholder="Projekt-ID*" />
|
placeholder="Projekt-ID*" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<div class="is-row">
|
<div class="is-row">
|
||||||
<div class="is-col">
|
<div class="is-col">
|
||||||
<input required type="input" size="32"
|
<input required type="input" size="32"
|
||||||
` name="realname" placeholder="Realname*" />
|
` id="realname" name="realname" placeholder="Realname*" />
|
||||||
</div>
|
</div>
|
||||||
<div class="is-col">
|
<div class="is-col">
|
||||||
</div>
|
</div>
|
||||||
|
@ -224,7 +224,8 @@
|
||||||
</div>
|
</div>
|
||||||
<button onclick="addTableRow();"
|
<button onclick="addTableRow();"
|
||||||
class="button is-green">Antrag elektronisch versenden</button>
|
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>
|
class="button is-orange">Herunterladen</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
48
kaform.js
48
kaform.js
|
@ -29,7 +29,7 @@ function deleteTableRow(rowId){
|
||||||
|
|
||||||
var target = document.getElementById("upload-target"+rowId);
|
var target = document.getElementById("upload-target"+rowId);
|
||||||
// this.message = app.message;
|
// this.message = app.message;
|
||||||
var children = target.children;
|
// var children = target.children;
|
||||||
|
|
||||||
// delete all uploaded elements
|
// delete all uploaded elements
|
||||||
/* for (var i = 0; i < children.length; i++) {
|
/* 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) {
|
function showAlert(text) {
|
||||||
|
|
||||||
$K.app.message.show( { message: `${text}`, position: 'centered', type: 'is-error' });
|
$K.app.message.show( { message: `${text}`, position: 'centered', type: 'is-error' });
|
||||||
|
@ -210,7 +221,7 @@ $K.add('module', 'kaform', {
|
||||||
opened: function(sender)
|
opened: function(sender)
|
||||||
{
|
{
|
||||||
console.log('Tab box is ',sender.getActiveBox());
|
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();
|
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
|
// add on table row
|
||||||
//addTableRow();
|
//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üge mind. eine Auslage hinzu!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("theform").submit();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue