"; // ---------------------------------------------------- // Fonction de création de test d'un champs contre une valeur // ---------------------------------------------------- function test_field_value_comp($form, $el1, $condition, $val, $message) { $script = ""; switch ($condition) { case 'GREATER': $symbol = ">"; break; case 'GREATER_EQUAL': $symbol = ">="; break; case 'LESSER': $symbol = "<"; break; case 'LESSER_EQUAL': $symbol = "<="; break; case 'EQUAL': $symbol = "=="; break; case 'DIFFERENT': $symbol = "!="; break; default: return ""; } $script = " if ($form.$el1.value $symbol $val) { alert(\"$message\"); $form.$el1.focus(); return false; }"; return $script; } // ---------------------------------------------------- // Fonction de création de test de deux champs de formulaire // ---------------------------------------------------- function test_field_el_comp($form, $el1, $condition, $el2, $message) { $script = ""; switch ($condition) { case 'GREATER': $symbol = ">"; break; case 'GREATER_EQUAL': $symbol = ">="; break; case 'LESSER': $symbol = "<"; break; case 'LESSER_EQUAL': $symbol = "<="; break; case 'EQUAL': $symbol = "=="; break; case 'DIFFERENT': $symbol = "!="; break; default: return ""; } $script = " if ($form.$el1.value $symbol form.$el2.value) { alert(\"$msg\"); $form.$el2.focus(); }"; return $script; } // ---------------------------------------------------- // Fonction de création de test d'un champ de formulaire // ---------------------------------------------------- function test_field($form, $element, $field_name, $restrictions=ALLOW_ALL) { $script = ""; if ($restrictions & DENY_EMPTY) { $script .= " if ($form.$element.value.length == 0) { alert(\"Vous devez saisir quelque chose pour le champ $field_name\"); $form.$element.focus(); return false; }"; } if ($restrictions & DENY_ALPHA) { $script .= " var exp = new RegExp('[a-zA-Z]','g'); if(exp.test($form.$element.value)) { alert(\"Vous ne pouvez pas entrer de caractères alphabétiques pour le champ $field_name\"); $form.$element.focus(); return false; }"; } if ($restrictions & DENY_NUM) { $script .= " var exp = new RegExp('[0-9]','g'); if(exp.test($form.$element.value)) { alert(\"Vous ne pouvez pas entrer de caractères numériques pour le champ $field_name\"); $form.$element.focus(); return false; }"; } if(!defined('SUPPPRESS_SPACES')) define('SUPPPRESS_SPACES', 0); if ($restrictions & SUPPPRESS_SPACES) { $script .= " $form.$element.value = $form.$element.value.replace(/ /g, '');"; } return $script; } function form_focus($form, $element) { $script = " "; return $script; } } // fin de définition