<?php function verif_ncpt() { // Pour les variables en javascript je pense que tu // Trouveras facilement... $a= ''; // Pour récuperer le contenu de ton champ "pncpt" // Fais des recherche du coté des sélécteurs JavaScript // (document.getElementById ou document.form.element...) $b=$_POST["pncpt"]; // Le for, tu trouveras aussi facilement... for ($i=0;$i<10;$i++) { // La concaténation en javascript se fais avec un plus $a=$a . $b[$i]; } // concaténation... $c=$b[10] . $b[11]; // Bon la je ne t'explique pas... $resul=$a / 97; // Alors la ca se corse... Pour l'ABS, tu le trouveras dans Math.abs // Pour la fonction intval, le code en bas de message pourras t'aider... $entier=intval(abs($resul)); // Ici ca devrais aller... $resulb=$entier * 97; $resulc=$a - $resulb; // Ici aussi... if ($c==$resulc) { ?> <script language="javascript"> alert('Le numéro est correct!'); </script> <?php } else ?> <script language="javascript"> alert('Le numéro est incorrect'); </script> <?php } ?>
function intval (mixed_var, base) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: stensi // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // * example 1: intval('Kevin van Zonneveld'); // * returns 1: 0 // * example 2: intval(4.2); // * returns 2: 4 // * example 3: intval(42, 8); // * returns 3: 42 // * example 4: intval('09'); // * returns 4: 9 var tmp; var type = typeof( mixed_var ); if (type == 'boolean'){ if (mixed_var == true) { return 1; } else { return 0; } } else if (type == 'string'){ tmp = parseInt(mixed_var * 1, 10); if (isNaN(tmp) || !isFinite(tmp)){ return 0; } else{ return tmp.toString(base || 10); } } else if (type == 'number' && isFinite(mixed_var) ){ return Math.floor(mixed_var); } else{ return 0; } }