Capturer un évènement textarea avec Tiny

Bonsoir

J'ai besoin de savoir si un champ textarea est bien rempli avant de valider le formulaire
Il s'agit du champ "faits", géré avec tiny.
De ce que j'ai compris, tiny mets le textarea d'origine en display:none et ajout par dessus une iframe.

Dans l'immédiat, un onchange, posé sur le form, me déclenche un script qui cherche à savoir s'il y a le caractère <, correspondant à la balise <p> ajoutée en systématique par tiny dés que l'on saisi quelque chose.
Mais le onchange ne fonctionne sur un champ géré par Tiny. Ce qui est en soit assez logique puisque tiny ne fait parti des objets du formulaire...

Comment puis-je capturer l'événement sur un changement de texte dans tiny ?


Code PHP :
Pour copier le contenu exact du code,
Veuillez citer le message
  1. <?php  
  2. #####!!!#####
  3.  
  4. var ch_obligatoire = new Array("sql_dt_incident","faits","sql_declarant_fonction","sql_connu");
  5. var caption_obligatoire = new Array("sql_dt_incident","caption_faits","sql_declarant_fonction","sql_connu");
  6. for(var i= 0; i < ch_obligatoire.length; i++) {
  7.                     if (document.getElementById(ch_obligatoire[i]).type == "select-one") {
  8.                         if (document.getElementById(ch_obligatoire[i]).selectedIndex == "0") {
  9.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "#ff4444";
  10.                             num_ch_nok = -1;
  11.                         } else {
  12.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "";
  13.                         }
  14.                     } else if (document.getElementById(ch_obligatoire[i]).type == "textarea") {
  15.                         var ma_txt = document.getElementById(ch_obligatoire[i]+"_ifr").contentDocument.body.innerText.charCodeAt(0);
  16.                         if (ma_txt == "10" || isNaN(ma_txt)) {
  17.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "#ff4444";
  18.                             num_ch_nok = -1;
  19.                         } else {
  20.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "";
  21.                         }
  22.                     } else {
  23.                         if (document.getElementById(ch_obligatoire[i]).value == "") {
  24.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "#ff4444";
  25.                             num_ch_nok = -1;
  26.                         } else {
  27.                             document.getElementById(caption_obligatoire[i]).style.backgroundColor = "";
  28.                         }
  29.                     }
  30.                 }
  31.  
  32. #####!!!#####
  33. ?>


Sujet écrit par Fifi69 le lundi 20 octobre 2014 à 17:22

[ Imprimer ] - [ Fermer la fenêtre ]