[ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 /* $Id: indexes.js 7886 2005-11-23 19:10:30Z nijel $ */ 2 3 4 /** 5 * Ensures a value submitted in a form is numeric and is in a range 6 * 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 11 * 12 * @return boolean whether a valid number has been submitted or not 13 */ 14 function checkFormElementInRange(theForm, theFieldName, message, min, max) 15 { 16 var theField = theForm.elements[theFieldName]; 17 var val = parseInt(theField.value); 18 19 if (typeof(min) == 'undefined') { 20 min = 0; 21 } 22 if (typeof(max) == 'undefined') { 23 max = Number.MAX_VALUE; 24 } 25 26 // It's not a number 27 if (isNaN(val)) { 28 theField.select(); 29 alert(errorMsg1); 30 theField.focus(); 31 return false; 32 } 33 // It's a number but it is not between min and max 34 else if (val < min || val > max) { 35 theField.select(); 36 alert(message.replace('%d', val)); 37 theField.focus(); 38 return false; 39 } 40 // It's a valid number 41 else { 42 theField.value = val; 43 } 44 45 return true; 46 } // end of the 'checkFormElementInRange()' function 47 48 49 /** 50 * Ensures indexes names are valid according to their type and, for a primary 51 * key, lock index name to 'PRIMARY' 52 * 53 * @return boolean false if there is no index form, true else 54 */ 55 function checkIndexName() 56 { 57 if (typeof(document.forms['index_frm']) == 'undefined') { 58 return false; 59 } 60 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']; 64 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; 70 } 71 } 72 73 // Other cases 74 else { 75 if (the_idx_name.value == 'PRIMARY') { 76 document.forms['index_frm'].elements['index'].value = ''; 77 } 78 if (typeof(the_idx_name.disabled) != 'undefined') { 79 document.forms['index_frm'].elements['index'].disabled = false; 80 } 81 } 82 83 return true; 84 } // end of the 'checkIndexName()' function 85 86 87 onload = checkIndexName;
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |