5 * Ensures a value submitted in a form is numeric and is in a range
7 * @param object the form
8 * @param string the name of the form field to check
9 * @param integer the minimum authorized value
10 * @param integer the maximum authorized value
12 * @return boolean whether a valid number has been submitted or not
14 function checkFormElementInRange(theForm, theFieldName, min, max)
16 var theField = theForm.elements[theFieldName];
17 var val = parseInt(theField.value);
19 if (typeof(min) == 'undefined') {
22 if (typeof(max) == 'undefined') {
23 max = Number.MAX_VALUE;
33 // It's a number but it is not between min and max
34 else if (val < min || val > max) {
36 alert(val + errorMsg2);
40 // It's a valid number
46 } // end of the 'checkFormElementInRange()' function
50 * Ensures indexes names are valid according to their type and, for a primary
51 * key, lock index name to 'PRIMARY'
53 * @return boolean false if there is no index form, true else
55 function checkIndexName()
57 if (typeof(document.forms['index_frm']) == 'undefined') {
61 // Gets the elements pointers
62 var the_idx_name = document.forms['index_frm'].elements['index'];
63 var the_idx_type = document.forms['index_frm'].elements['index_type'];
65 // Index is a primary key
66 if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
67 document.forms['index_frm'].elements['index'].value = 'PRIMARY';
68 if (typeof(the_idx_name.disabled) != 'undefined') {
69 document.forms['index_frm'].elements['index'].disabled = true;
75 if (the_idx_name.value == 'PRIMARY') {
76 document.forms['index_frm'].elements['index'].value = '';
78 if (typeof(the_idx_name.disabled) != 'undefined') {
79 document.forms['index_frm'].elements['index'].disabled = false;
84 } // end of the 'checkIndexName()' function
87 onload = checkIndexName;