bug #1207405, invalid SQL when creating table with zero fields
This commit is contained in:
@@ -218,7 +218,7 @@ function checkSqlQuery(theForm)
|
||||
|
||||
|
||||
/**
|
||||
* Displays an error message if an element of a form hasn't been completed and
|
||||
* Check if a form's element is empty
|
||||
* should be
|
||||
*
|
||||
* @param object the form
|
||||
@@ -226,7 +226,7 @@ function checkSqlQuery(theForm)
|
||||
*
|
||||
* @return boolean whether the form field is empty or not
|
||||
*/
|
||||
function emptyFormElements(theForm, theFieldName)
|
||||
function emptyCheckTheField(theForm, theFieldName)
|
||||
{
|
||||
var isEmpty = 1;
|
||||
var theField = theForm.elements[theFieldName];
|
||||
@@ -239,6 +239,25 @@ function emptyFormElements(theForm, theFieldName)
|
||||
var space_re = new RegExp('\\s+');
|
||||
isEmpty = (theField.value.replace(space_re, '') == '') ? 1 : 0;
|
||||
}
|
||||
|
||||
return isEmpty;
|
||||
} // end of the 'emptyCheckTheField()' function
|
||||
|
||||
|
||||
/**
|
||||
* Displays an error message if an element of a form hasn't been completed and
|
||||
* should be
|
||||
*
|
||||
* @param object the form
|
||||
* @param string the name of the form field to put the focus on
|
||||
*
|
||||
* @return boolean whether the form field is empty or not
|
||||
*/
|
||||
function emptyFormElements(theForm, theFieldName)
|
||||
{
|
||||
var theField = theForm.elements[theFieldName];
|
||||
isEmpty = emptyCheckTheField(theForm, theFieldName);
|
||||
|
||||
if (isEmpty) {
|
||||
theForm.reset();
|
||||
theField.select();
|
||||
@@ -291,12 +310,18 @@ function checkFormElementInRange(theForm, theFieldName, min, max)
|
||||
else {
|
||||
theField.value = val;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end of the 'checkFormElementInRange()' function
|
||||
|
||||
|
||||
function checkTableEditForm(theForm, fieldsCnt)
|
||||
{
|
||||
// TODO: avoid sending a message if user just wants to add a line
|
||||
// on the form but has not completed at least one field name
|
||||
|
||||
var atLeastOneField = 0;
|
||||
|
||||
for (i=0; i<fieldsCnt; i++)
|
||||
{
|
||||
var id = "field_" + i + "_2";
|
||||
@@ -312,7 +337,21 @@ function checkTableEditForm(theForm, fieldsCnt)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (atLeastOneField == 0) {
|
||||
var id = "field_" + i + "_1";
|
||||
if (!emptyCheckTheField(theForm, id)) {
|
||||
atLeastOneField = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (atLeastOneField == 0) {
|
||||
var theField = theForm.elements["field_0_1"];
|
||||
alert(errorMsg0);
|
||||
theField.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // enf of the 'checkTableEditForm()' function
|
||||
|
||||
|
Reference in New Issue
Block a user