54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
|
|
function IsNumeric(sText) {
|
||
|
|
var ValidChars = "0123456789";
|
||
|
|
var IsNumber=true;
|
||
|
|
var Char;
|
||
|
|
for (i = 0; i < sText.length && IsNumber == true; i++) {
|
||
|
|
Char = sText.charAt(i);
|
||
|
|
if (ValidChars.indexOf(Char) == -1) {
|
||
|
|
IsNumber = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return IsNumber;
|
||
|
|
}
|
||
|
|
|
||
|
|
function form1Submit() {
|
||
|
|
//check if form is well filled
|
||
|
|
//Minimum of two words required
|
||
|
|
var word1 = document.getElementById('word01').value;
|
||
|
|
var word2 = document.getElementById('word02').value;
|
||
|
|
var width = document.getElementById('width').value;
|
||
|
|
var height = document.getElementById('height').value;
|
||
|
|
if (word1.length <= 0) {
|
||
|
|
document.getElementById('status').innerHTML = 'Minimum of two words required';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (word2.length <= 0) {
|
||
|
|
document.getElementById('status').innerHTML = 'Minimum of two words required';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (width.length <= 0) {
|
||
|
|
document.getElementById('status').innerHTML = 'Value <b>width</b> required';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (height.length <= 0) {
|
||
|
|
document.getElementById('status').innerHTML = 'Value <b>height</b> required';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!IsNumeric(width)) {
|
||
|
|
document.getElementById('status').innerHTML = 'Value <b>width</b> needs numeric input';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!IsNumeric(height)) {
|
||
|
|
document.getElementById('status').innerHTML = 'Value <b>height</b> needs numeric input';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
//tests ok
|
||
|
|
document.getElementById('status').innerHTML = ' ';
|
||
|
|
//download image visible and form invisible
|
||
|
|
document.getElementById('loading').style.visibility = 'visible';
|
||
|
|
document.getElementById('form1').style.visibility = 'hidden';
|
||
|
|
//document.getElementById('inpNrs').style.visibility = 'hidden';
|
||
|
|
|
||
|
|
//go for it!
|
||
|
|
document.getElementById('form1').submit();
|
||
|
|
}
|