Bonjour,

Je souhaite faire une fonction Javascript qui vérifie si un champ de formulaire contient des caractères accentués pour passer à la suite ou non.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
function getListeAC(monChamp, monId, lookupName){
	if (document.getElementById('_1_1_214_1').value!="yes"){
		var noaccent = new RegExp('[éè]');
		if ( noaccent.test(document.myForm._1_1_216_1.value) == true ) {
			alert ("haha, ya un accent !");}
		else {
			<blabla>
		}
	}
}
La fonction est appelée sur un onfocus sur un autre champ. A terme, je mettrai tous les caractères accentués possibles.

Le champs du formulaire en question est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
&nbsp;<SELECT CLASS="selectMenu" ID="_1_1_216_1" NAME="_1_1_216_1" ONCHANGE="markDirty();">
<OPTION VALUE="" >&lt;Aucun&gt;</OPTION>
<OPTION VALUE="Bidon Alu / Aluminium can" >Bidon Alu / Aluminium can</OPTION>
<OPTION VALUE="Boitier / Compact" >Boitier / Compact</OPTION>
<OPTION VALUE="Capot tige, Mascara, Gloss, VAO / Cap + Handle" >Capot tige, Mascara, Gloss, VAO / Cap + Handle</OPTION>
<OPTION VALUE="Coffret / Gift box" >Coffret / Gift box</OPTION>
<OPTION VALUE="Coiffe, Capot, Capsule / Cover, Cap, Screw cap" >Coiffe, Capot, Capsule / Cover, Cap, Screw cap</OPTION>
<OPTION VALUE="Colleret, Frette métal" >Colleret, Frette métal</OPTION>
<OPTION VALUE="Composants multiples, divers (métal, plastique, verre) / Multi components" >Composants multiples, divers (métal, plastique, verre) / Multi components</OPTION>
<OPTION VALUE="Etiquette / Label" >Etiquette / Label</OPTION>
<OPTION VALUE="Etui / Folding box" >Etui / Folding box</OPTION>
<OPTION VALUE="Films, cello / Printed wrapping film" >Films, cello / Printed wrapping film</OPTION>
<OPTION VALUE="Flacon plastique / Plastic bottle" >Flacon plastique / Plastic bottle</OPTION>
<OPTION VALUE="Flacon verre / Glass bottle" >Flacon verre / Glass bottle</OPTION>
<OPTION VALUE="Flaconette Mascara / Gloss / Mascara / Gloss bottle" >Flaconette Mascara / Gloss / Mascara / Gloss bottle</OPTION>
<OPTION VALUE="Godet / Metal pan" >Godet / Metal pan</OPTION>
<OPTION VALUE="Houpette, Eponge /  Puff, Sponge" >Houpette, Eponge /  Puff, Sponge</OPTION>
<OPTION VALUE="Kit pompe / Pump kit" >Kit pompe / Pump kit</OPTION>
<OPTION VALUE="Mécanisme tournant / Rotated mechanism" >Mécanisme tournant / Rotated mechanism</OPTION>
<OPTION VALUE="Notice / Leaflet" >Notice / Leaflet</OPTION>
<OPTION VALUE="Ondulé / Corrugated cardboard" >Ondulé / Corrugated cardboard</OPTION>
<OPTION VALUE="Opercule / Membrane seal" >Opercule / Membrane seal</OPTION>
<OPTION VALUE="Pack tertiaire" >Pack tertiaire</OPTION>
<OPTION VALUE="Pinceau, Applicateur / Brush, Applicator" >Pinceau, Applicateur / Brush, Applicator</OPTION>
<OPTION VALUE="Pot plastique / Plastic jar" >Pot plastique / Plastic jar</OPTION>
<OPTION VALUE="Pot verre / Glass jar" >Pot verre / Glass jar</OPTION>
<OPTION VALUE="RAL / KAJAL" >RAL / KAJAL</OPTION>
<OPTION VALUE="Rhodoïd, Thermo / Rhodoid, Thermo" >Rhodoïd, Thermo / Rhodoid, Thermo</OPTION>
<OPTION VALUE="Sachet, Masque / In pack, Mask" >Sachet, Masque / In pack, Mask</OPTION>
<OPTION VALUE="Trousse, Suédine / Pouch" >Trousse, Suédine / Pouch</OPTION>
<OPTION VALUE="Tube / Tube" >Tube / Tube</OPTION>
</SELECT>


Ma fonction est sans doute bonne, car si je tente new RegExp('[hz]'); il m'alerte bien lorsque le choix contient un 'h' ou un 'z'
J'ai alors penché sur des questions d'encodage, mais je ne sais pas ce que je dois regarder. Mon fichier js est en ANSI.
Je vais voir si le problème se produit en prenant non pas la valeur de l'option, mais son label.

Merci d'avance pour votre aide,