Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > AJAX
AJAX Forum sur la programmation AJAX. Avant de poster : Cours AJAX, FAQ AJAX, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/05/2011, 16h52   #1
Nouveau Membre du Club
 
Inscription : janvier 2006
Messages : 122
Détails du profil
Informations forums :
Inscription : janvier 2006
Messages : 122
Points : 28
Points : 28
Par défaut Positionnement page après Validation formulaire

Bonjour,

J'ai un formulaire où je contrôle les champs en ajax notamment prototype et script aculeous.

A la validation du formulaire, quand il y a une erreur dans un champ de formulaire, j'affiche un message d'erreur en haut du formulaire.

Toutefois, quand je valide le formulaire, et qu'il y a une erreur, on me demande de positionner la page là où se trouve le message d'erreur mais je ne sais pas comment faire?

Je pensais utiliser une ancre mais je ne vois pas comment lui dire de se positionner vers l'ancre que j'aurais placée.

Je fais quelque chose de ce type pour valider les champs obligatoires:
Code :
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
 
<script type="text/javascript">
<!--
 
var userConnectForm = new FormValidator("formTab", true);
var fv1 = new Array();
 
fv1.push( new MandatoryFormFieldConstraint("login", { label: $("crea_mail"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.email.empty" /></noheto:str>' } ));
fv1.push( new PatternFormFieldConstraint("login", { label: $("crea_mail"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.email.syntax" /></noheto:str>', pattern: /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/ } ));
 
fv1.push( new MandatoryFormFieldConstraint("civilite", { label: $("civilite"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.civilite.empty" /></noheto:str>' } ));
fv1.push( new MandatoryFormFieldConstraint("modif_nom", { label: $("modif_nom"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.nom.empty" /></noheto:str>' } ));
fv1.push( new PatternFormFieldConstraint("modif_nom", { label: $("modif_nom"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.nom.syntax" /></noheto:str>', pattern: /^[A-Za-z- éèêëàâîïôöùûüç]*$/ } ));
fv1.push( new MandatoryFormFieldConstraint("modif_prenom", { label: $("modif_prenom"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.prenom.empty" /></noheto:str>' } ));
fv1.push( new PatternFormFieldConstraint("modif_prenom", { label: $("modif_prenom"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.prenom.syntax" /></noheto:str>', pattern: /^[A-Za-z- éèêëàâîïôöùûüç]*$/ } ));
fv1.push( new MandatoryFormFieldConstraint("forms-select", { label: $("forms-select"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.secteur.empty" /></noheto:str>' } ));
 
fv1.push( new MandatoryFormFieldConstraint("modif_cp", { label: $("modif_cp"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.codepostal.syntax" /></noheto:str>'} ));
fv1.push( new PatternFormFieldConstraint("modif_cp", { label: $("modif_cp"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.codepostal.syntax" /></noheto:str>', pattern: /^[0-9]{5}$/ } ));
fv1.push( new PatternFormFieldConstraint("modif_country", { label: $("modif_country"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.pays.syntax" /></noheto:str>', pattern: /^[A-Za-z- éèêëàâîïôöùûüç]*$/ } ));
fv1.push( new PatternFormFieldConstraint("modif_tel", { label: $("modif_tel"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.telephone.syntax" /></noheto:str>', pattern: /^[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}$/ } ));
fv1.push( new PatternFormFieldConstraint("modif_fax", { label: $("modif_fax"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.fax.syntax" /></noheto:str>', pattern: /^[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}[ ]?[0-9]{2}$/ } ));
fv1.push( new PatternFormFieldConstraint("modif_numintracomm", { label: $("modif_numintracomm"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.numintracomm.syntax" /></noheto:str>', pattern: /^(RO\d{2,10}|GB\d{5}|(ATU|DK|FI|HU|LU|MT|CZ|SI)\d{8}|IE[A-Z\d]{8}|(DE|BG|EE|EL|LT|BE0|PT|CZ)\d{9}|CY\d{8}[A-Z]|(ES|GB)[A-Z\d]{9}|(BE0|PL|SK|CZ)\d{10}|(FR|IT|LV)\d{11}|(LT|SE)\d{12}|(NL|GB)[A-Z\d]{12})$/ } ));
fv1.push( new verifFRConstraint("modif_numintracomm", { label: $("modif_numintracomm"), errorMessage: '<noheto:str escapeJS="true"><noheto:message bundle="${frontBundle}" key="formulaire.error.numintracomm.frenchcase" /></noheto:str>', pays : "modif_country" } ));
 
userConnectForm.addFieldsConstraints(fv1); 
 
 
//-->
</script>
Voici commence mon formulaire
Code :
1
2
 
<form method="post" action="<noheto:url value="/objects/userfo/front/common/actions/update_account.jspz" />" id="formTab">
La validation marche ainsi que l'affichage du message d'erreur mais pour savoir comment placer l'ancre c'est autre chose.
j'ai placé une ancre au dessus du formulaire mais je ne sais pas comment dire à l'ajax de se positionner dessus.

J'ai mis sur l'url du formulaire un #ancre par exemple mais ça ne peut pas marcher car l'action ne se fait pas sur la jsp du formulaire mais à travers une autre jsp qui fait revenir vers le formulaire.

Merci d'avance pour votre aide et votre compréhension
zekabyle est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 11h41.


 
 
 
 
Partenaires

Hébergement Web