1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * function used for index manipulation pages
8 * Ensures a value submitted in a form is numeric and is in a range
10 * @param object the form
11 * @param string the name of the form field to check
12 * @param integer the minimum authorized value
13 * @param integer the maximum authorized value
15 * @return boolean whether a valid number has been submitted or not
17 function checkFormElementInRange(theForm, theFieldName, message, min, max)
19 var theField = theForm.elements[theFieldName];
20 var val = parseInt(theField.value);
22 if (typeof(min) == 'undefined') {
25 if (typeof(max) == 'undefined') {
26 max = Number.MAX_VALUE;
32 alert(PMA_messages['strNotNumber']);
36 // It's a number but it is not between min and max
37 else if (val < min || val > max) {
39 alert(message.replace('%d', val));
43 // It's a valid number
49 } // end of the 'checkFormElementInRange()' function
53 * Ensures indexes names are valid according to their type and, for a primary
54 * key, lock index name to 'PRIMARY'
56 * @return boolean false if there is no index form, true else
58 function checkIndexName()
60 if (typeof(document.forms['index_frm']) == 'undefined') {
64 // Gets the elements pointers
65 var the_idx_name = document.forms['index_frm'].elements['index'];
66 var the_idx_type = document.forms['index_frm'].elements['index_type'];
68 // Index is a primary key
69 if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
70 document.forms['index_frm'].elements['index'].value = 'PRIMARY';
71 if (typeof(the_idx_name.disabled) != 'undefined') {
72 document.forms['index_frm'].elements['index'].disabled = true;
78 if (the_idx_name.value == 'PRIMARY') {
79 document.forms['index_frm'].elements['index'].value = '';
81 if (typeof(the_idx_name.disabled) != 'undefined') {
82 document.forms['index_frm'].elements['index'].disabled = false;
87 } // end of the 'checkIndexName()' function
90 onload = checkIndexName;