form validation

P

pascal scalpa

hello
I try to deal with a form using this code : it works with firefox but
not with ie.... I spent a lot of time trying to debugging without
success: any idea please?
this code is based on An example here :
<!-- saved from url=(0081)http://www.javascript-coder.com/html-form/
javascript-form-validation-example.html -->

thanks
pascal

The example below shows a case where the action field is switched
based on the selection in the radio buttons.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0081)http://www.javascript-coder.com/html-form/
javascript-form-validation-example.html -->
<HTML>
<HEAD>
<TITLE>JavaScript Form Validation example</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-
Type>

<SCRIPT language=JavaScript type=text/javascript src="./
gen_validatorv31.js"></SCRIPT>
</HEAD>
<BODY>
<script language="JavaScript">
//<![CDATA[
<!--
//Choix de la page
function OnSubmitForm()
{
frm=document.forms['myform'];
if(frm.elements['matiere'][0].checked == true)
{
frm.action ="a.htm";
}
else
if(frm.elements['matiere'][1].checked == true)
{
frm.action ="b.htm";
}
return document.myform.runvalidation();

}
-->
//]]>
</script>

<blockquote><p>Pour que les résultats des élèves d'une même classe
soient enregistrés dans le même fichier,
il est impératif que chacun fasse <strong>AVANT TOUTE CHOSE</strong>
le même choix à l'étape n°1.</p></blockquote>

<form name="myform" onsubmit="return OnSubmitForm()" >
<fieldset><legend>ETAPE N°1</legend>
Choisir sa classe actuelle.<br />
<select id="classe_actuelle" name="classe_actuelle">
<option label="???" value="0">???</option>
<option label="M. Bazin" value="bazin">M. Bazin</option>
<option label="M. Chalopin" value="chalopin">M. Chalopin</option>
<option label="M. Le Morvan" value="lemorvan">M. Le Morvan</option>
<option label="Invité" value="invite">Invité</option>
</select></fieldset>


<fieldset><legend>ETAPE N°2</legend>
Choisir la matière.<br />
<input id="voca" name="matiere" type="radio" value="0" />Vocabulaire
<input id="conj" name="matiere" type="radio" value="1" />Conjugaison
<input id="gram" name="matiere" type="radio" value="2" />Grammaire
<input id="orth" name="matiere" type="radio" value="3" />Orthographe
<input id="lect" name="matiere" type="radio" value="4" />Lecture
</fieldset>

<fieldset><legend>ETAPE N°3</legend>
S'identifier.<br />
<table summary="formulaire d'inscription">
<tr><td>Entrez votre pr&eacute;nom : </td> <td><input type="text"
id="prenom" name="prenom" size="30"/></td></tr>
<tr><td>Entrez votre nom : </td> <td> <input type="text" id="nom"
name="nom" size="30"/></td></tr>
<tr><td>De quel sexe êtes vous ?</td> <td>
<input type="radio" id="sexeH" name="sexe" value="Garçon"/>
<label for="sexeH">Garçon</label>
<input type="radio" id="sexeF" name="sexe" value="Fille"/>
<label for="sexeF">Fille</label></td></tr>
<tr><td><label for="classe">Entrez votre classe d'origine : </label></
td>
<td>
<select id="classe_origine" name="classe_origine">
<option value="0">???</option>
<option value="Bazin">Bazin</option>
<option value="Le Morvan">Le Morvan</option>
<option value="Autre">Autre</option>
</select></td></tr>
<tr><td><input name="submit" type="submit" value="S'inscrire"/></
td><td><input type="reset" value="Effacer"/></td></tr>
</table>

</fieldset>
</form>

<div id='myform_errorloc' class='error_strings'></div>

<SCRIPT language=JavaScript type=text/javascript>
var frmvalidator = new Validator("myform");
//frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("classe_actuelle","dontselect=0","Quelle
est ta classe actuelle?");
frmvalidator.addValidation("matiere","selone_radio","Choisis une
matière.");
frmvalidator.addValidation("prenom","req","Ecris ton prénom.");
frmvalidator.addValidation("prenom","alpha");
frmvalidator.addValidation("nom","req","Ecris ton nom.");
frmvalidator.addValidation("nom","alpha");
frmvalidator.addValidation("sexe","selone_radio","Es-tu un garçon ou
une fille?");
frmvalidator.addValidation("classe_origine","dontselect=0","Quelle
est ta classe d'origine?");
</SCRIPT>

<script language="JavaScript">
document.myform.runvalidation = document.myform.onsubmit;
document.myform.onsubmit = OnSubmitForm;// here is the problem with
IE8
</script>

</BODY></HTML
 
S

SAM

Le 8/19/09 3:40 PM, pascal scalpa a écrit :
hello
I try to deal with a form using this code : it works with firefox but
not with ie.... I spent a lot of time trying to debugging without
success: any idea please?

What did tell the Firefox consol errors ?
Qu'est-ce que la console d'erreurs de Firefox te dit ?
- à l'ouverture du fichier
- au submit.
M'étonnerait qu'elle reste muette.
Même si elle ne bloque pas (tout) le JS.

Load your file in Fx while its console in opened by side.
menu: Outils / Console d'erreurs
On my idea it is because the JS doesn't run to end that it "works" in Fx.

OP's code in his previous post
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top