ok so here is my function
Code
function Valider(objet)
{
var chaine = document.getElementById(objet.id).value;
switch(objet.id)
{
case "telephone":
break;
case "code_postal":
var code_postal = new RegExp("^[A-Z]\d[A-Z][\s-]?\d[A-Z]\d$");
if(code_postal.test(chaine) == true)
alert(true);
else
alert(false);
break;
case "date":
break;
case "nas":
break;
case "courriel":
break;
case "adr_internet":
break;
case "nbr_decimal":
document.getElementById(objet.id).value = chaine.replace(",",".");
break;
}
}
ok so objet is the input that was sent to the function.
id like to know how to make my case "code_postal" work ... because i have tryed .test and .exec with various way to write it but i cant get it to work ...
btw my RegExp is supose to let pass (cap letter) number (cap letter) space - or nothing number (cap letter) number --> for those who aren't familiar with RegExp
those are supose to be ok:
A9A9A9
A9A 9A9
A9A-9A9
my RegExp is correct and let only pass what it should (tested it on a tester website) but idk how to apply it correctly in my code
any help is really appreciate
This post was edited by djray on May 19 2012 12:31pm