Struts,javascripts(valider un formulaire coté client)

kawti Messages postés 11 Date d'inscription dimanche 2 juillet 2006 Statut Membre Dernière intervention 9 juin 2007 - 30 mai 2007 à 20:29
super_toinou Messages postés 764 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 8 mars 2011 - 31 mai 2007 à 16:35
bonjour
je travail sur une application web avec struts , j'ai créer un formulaire dns une page jsp
je veux faire la validation de mon formulaire coté client avec javascript et j'ai essayer d'intégrer u n code mais il ne marche pas  voila mon code tout entier :




<%@ page language="java" pageEncoding="ISO-8859-1"%>


<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>



<%@ taglib uri="
http://jakarta.apache.org/struts/tags-html
" prefix="html"%>




<html>


<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<title>changer le Mot de passe </title>


<script language="JavaScript">


<!--


function Verif() {


var msg = "";


// Champ 1 saisi ?


if (document.form1.amotpasse.value.length <= 0) {


msg += "\n - l'ancien mot de passe";


}




// Champ 2 saisi ?


if (document.form1.nmotpass.value.length <= 0) {


msg += "\n - le nouveau mot de passe";


}


if (document.form1.confmotpasse.value.length <= 0) {


msg += "\n - confirmer mot de passe";


}


if (document.form1.nmotpass.value!=document.form1.confmotpasse.value){


msg += "\n - la confirmation du mot de passe est incorrecte";


}


// Si un problème => message d'erreur


if (msg != ""){


msg += alert(" Attention!!" + msg);


return false;


}




else {


// tout est bien rempli


return true;


}


}


// -->


</script>


 


 


<style type="text/css">


<!--


.Style2 { font-size: 12px;


color: #0000C4;


}


.Style5 { font-size: 12px;


color: #FF0000;


}


#Layer1 { position:absolute;


left:132px;


top:74px;


width:362px;


height:199px;


z-index:1;


background-color: #FFFFF2;


}


.Style1 { color: #FFFFFF;


font-weight: bold;


}


#Layer2 { position:absolute;


left:132px;


top:40px;


width:450px;


height:35px;


z-index:2;


background-color: #33CC33;


}


-->


</style>


</head>






<html:form action="/changer" id="form1" name="form1" method="post" onSubmit="return Verif();">




Ancien mot de passe :,

(*),

<label><html:password property="amotpasse"/><html:errors property="amotpasse"/>

</label>,

----

Nouveau mot de passe : ,

(*),

<label><html:password property="nmotpass"/><html:errors property="nmotpass"/>

</label>,

----

Confirmer le mot de passe :
,

(*),

<label><html:password property="confmotpasse"/><html:errors property="confmotpasse"/>

</label>,

----

,

 

<label><html:submit value="valider"/></label>,

<label><html:reset/></label>


</html:form>






Changr le mot de passe






</html>


 


 et voila l'erreur de tomcat:
org.apache.jasper.JasperException: /form/changer.jsp(73,1) L'attribut id est incorrect pour le tag form d'après la TLD indiquée
............
........
comment je pourais utiliser javascript sur mes page jsp,je ne veux pas faire la validatio coté serveurs car c cera trop long .
Remarque:j'ai essayer ce code sur dreamweaver et ca marche
plllllllzzzzzzz aidez moi

1 réponse

super_toinou Messages postés 764 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 8 mars 2011 6
31 mai 2007 à 16:35
Yopla,

j en sais rien parce que tu mets pas d id dans ton form néanmoins pourquoi
<form ... onSubmit="return Verif();">
et pas
<form ... onSubmit="Verif();">
Essaye de voir si c est ca


++ Toinou
0
Rejoignez-nous