1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * function used for index manipulation pages
9 * Ensures a value submitted in a form is numeric and is in a range
11 * @param object the form
12 * @param string the name of the form field to check
13 * @param integer the minimum authorized value
14 * @param integer the maximum authorized value
16 * @return boolean whether a valid number has been submitted or not
18 function checkFormElementInRange(theForm, theFieldName, message, min, max)
20 var theField = theForm.elements[theFieldName];
21 var val = parseInt(theField.value);
23 if (typeof(min) == 'undefined') {
26 if (typeof(max) == 'undefined') {
27 max = Number.MAX_VALUE;
37 // It's a number but it is not between min and max
38 else if (val < min || val > max) {
40 alert(message.replace('%d', val));
44 // It's a valid number
50 } // end of the 'checkFormElementInRange()' function
54 * Ensures indexes names are valid according to their type and, for a primary
55 * key, lock index name to 'PRIMARY'
57 * @return boolean false if there is no index form, true else
59 function checkIndexName()
61 if (typeof(document.forms['index_frm']) == 'undefined') {
65 // Gets the elements pointers
66 var the_idx_name = document.forms['index_frm'].elements['index'];
67 var the_idx_type = document.forms['index_frm'].elements['index_type'];
69 // Index is a primary key
70 if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
71 document.forms['index_frm'].elements['index'].value = 'PRIMARY';
72 if (typeof(the_idx_name.disabled) != 'undefined') {
73 document.forms['index_frm'].elements['index'].disabled = true;
79 if (the_idx_name.value == 'PRIMARY') {
80 document.forms['index_frm'].elements['index'].value = '';
82 if (typeof(the_idx_name.disabled) != 'undefined') {
83 document.forms['index_frm'].elements['index'].disabled = false;
88 } // end of the 'checkIndexName()' function
91 onload = checkIndexName;