Duplicated code
This commit is contained in:
@@ -4,51 +4,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensures a value submitted in a form is numeric and is in a range
|
|
||||||
*
|
|
||||||
* @param object the form
|
|
||||||
* @param string the name of the form field to check
|
|
||||||
* @param integer the minimum authorized value
|
|
||||||
* @param integer the maximum authorized value
|
|
||||||
*
|
|
||||||
* @return boolean whether a valid number has been submitted or not
|
|
||||||
*/
|
|
||||||
function checkFormElementInRange(theForm, theFieldName, message, min, max)
|
|
||||||
{
|
|
||||||
var theField = theForm.elements[theFieldName];
|
|
||||||
var val = parseInt(theField.value);
|
|
||||||
|
|
||||||
if (typeof(min) == 'undefined') {
|
|
||||||
min = 0;
|
|
||||||
}
|
|
||||||
if (typeof(max) == 'undefined') {
|
|
||||||
max = Number.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// It's not a number
|
|
||||||
if (isNaN(val)) {
|
|
||||||
theField.select();
|
|
||||||
alert(PMA_messages['strNotNumber']);
|
|
||||||
theField.focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// It's a number but it is not between min and max
|
|
||||||
else if (val < min || val > max) {
|
|
||||||
theField.select();
|
|
||||||
alert(message.replace('%d', val));
|
|
||||||
theField.focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// It's a valid number
|
|
||||||
else {
|
|
||||||
theField.value = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} // end of the 'checkFormElementInRange()' function
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures indexes names are valid according to their type and, for a primary
|
* Ensures indexes names are valid according to their type and, for a primary
|
||||||
* key, lock index name to 'PRIMARY'
|
* key, lock index name to 'PRIMARY'
|
||||||
|
Reference in New Issue
Block a user