IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

[ASP] Validation de formulaire qui ne fonctionne pas


Sujet :

ASP.NET

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Octobre 2008
    Messages
    73
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Octobre 2008
    Messages : 73
    Points : 59
    Points
    59
    Par défaut [ASP] Validation de formulaire qui ne fonctionne pas
    Bonjour à tous,

    je suis en pleine création d'une page d'inscription et de connexion (2 formulaires sur la même pages)

    j'ai bien séparé les deux formulaires avec "ValidationGroup", mais le formulaire se valide alors qu'il devrait renvoyer des erreurs

    voici mon code :
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    <asp:Content ID="Content2" ContentPlaceHolderID="corpsContent" Runat="Server">
        <asp:Panel ID="Connexion" runat="server">
            <h2>Vous êtes client?</h2>
            <h3>Connectez-vous :</h3>
            <asp:Table ID="tableLogin" runat="server">
                <asp:TableRow>
                    <asp:TableCell>Login :</asp:TableCell><asp:TableCell><asp:TextBox ID="tbLogin" runat="server" ValidationGroup="gConnexion"/></asp:TableCell><asp:TableCell>
                        <asp:RequiredFieldValidator
                                ID="rfvLogin"
                                EnableClientScript = "true"
                                ControlToValidate = "tbLogin"
                                text = "#"
                                ErrorMessage = "Champ obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell><asp:TableCell>                       
                        <asp:RegularExpressionValidator
                                ID="revLogin"
                                ValidationExpression = "^([\w.]+)@([\w]+)\.([\w]{2,3})$"
                                EnableClientScript = "true"
                                ControlToValidate = "tbLogin"
                                text = "*"
                                ErrorMessage = "Adresse mail invalide"
                                runat = "server"/>
                    </asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Mot de passe :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbMdp" TextMode = "Password" runat = "server" ValidationGroup="gConnexion"/></asp:TableCell><asp:TableCell>  
                        <asp:RequiredFieldValidator
                                ID="rfvMdp"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMdp"
                                text = "#"
                                ErrorMessage = "Champ obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell></asp:TableRow></asp:Table>
            <asp:Button class="btnValid" ID="validConnexion" runat="server" Text="Valider" ValidationGroup="gConnexion" OnClick="validConnexion_Click"/>
            <asp:Label ID="Label1" runat="server">
     
            </asp:Label><asp:ValidationSummary
                ValidationGroup="gConnexion"
                HeaderText = "Erreurs de saisie :"
                ID = "vsConnexion"
                EnableClientScript = "true"
                DisplayMode = "BulletList"
                runat = "server"
                Width = "400"/>    
        </asp:Panel>
     
        <asp:Panel ID="Inscription" runat="server">
            <h2>Pas encore inscrit?</h2><h3>30 secondes suffisent pour vous inscrire et accéder à nos offres! </h3><asp:Table ID="table1" runat="server">
                <asp:TableRow>
                    <asp:TableCell>Nom :</asp:TableCell><asp:TableCell><asp:TextBox ID="tbNom" runat="server" ValidationGroup="gInscription"/></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Prenom :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbPrenom" runat = "server" ValidationGroup="gInscription" /></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>N° de la rue :</asp:TableCell><asp:TableCell><asp:TextBox ID="tbNumRue" runat="server" width="60" ValidationGroup="gInscription"/></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Rue :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbRue" runat = "server" width="280" ValidationGroup="gInscription"/></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Code Postal :</asp:TableCell><asp:TableCell><asp:TextBox ID="tbCp" runat="server"  ValidationGroup="gInscription"/></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Ville :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbVille" runat = "server" ValidationGroup="gInscription" /></asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Pays :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbPays" runat = "server" ValidationGroup="gInscription" /></asp:TableCell></asp:TableRow></asp:Table><hr /><asp:Table ID="tableMail" runat="server">
                <asp:TableRow>
                    <asp:TableCell>Mail :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbMail" runat="server" width="200" ValidationGroup="gInscription"/></asp:TableCell><asp:TableCell>
                        <asp:RequiredFieldValidator
                                ID="rfvMail"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMail"
                                text = "#"
                                ErrorMessage = "Champs obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell><asp:TableCell>                       
                        <asp:RegularExpressionValidator
                                ID="revMail"
                                ValidationExpression = "^([\w.]+)@([\w]+)\.([\w]{2,3})$"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMail"
                                text = "*"
                                ErrorMessage = "Adresse mail invalide"
                                runat = "server"/>
                    </asp:TableCell><asp:TableCell>
                        <asp:CompareValidator
                            ID="cvMp"
                            EnableClientScript = "true"
                            ControlToValidate = "tbMail"
                            ControlToCompare = "tbMailConfirm"
                            text = "*"
                            ErrorMessage = "Champs obligatoire"
                            Enabled = "true"
                            runat = "server"/>
                    </asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Confirmation du mail :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbMailConfirm" runat = "server"  width="200" ValidationGroup="gInscription"/></asp:TableCell><asp:TableCell>
                        <asp:RequiredFieldValidator
                                ID="rfvMailConfirm"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMailConfirm"
                                text = "#"
                                ErrorMessage = "Champs obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell><asp:TableCell>                       
                        <asp:RegularExpressionValidator
                                ID="revMailConfirm"
                                ValidationExpression = "^([\w.]+)@([\w]+)\.([\w]{2,3})$"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMailConfirm"
                                text = "*"
                                ErrorMessage = "Adresse mail invalide"
                                runat = "server"/>
                    </asp:TableCell></asp:TableRow></asp:Table><hr /><asp:Table ID="tableMdp" runat="server">
                <asp:TableRow>
                    <asp:TableCell>Mot de passe :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbMdpInsc" TextMode = "Password" runat="server" ValidationGroup="gInscription"/></asp:TableCell><asp:TableCell>
                        <asp:RequiredFieldValidator
                                ID="rfvMdpInsc"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMdpInsc"
                                text = "#"
                                ErrorMessage = "Champs obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell><asp:TableCell>
                        <asp:CompareValidator
                            ID="cvMdpInsc"
                            EnableClientScript = "true"
                            ControlToValidate = "tbMdpInsc"
                            ControlToCompare = "tbMdpConfirm"
                            text = "*"
                            ErrorMessage = "Champs obligatoire"
                            Enabled = "true"
                            runat = "server"/>
                    </asp:TableCell></asp:TableRow><asp:TableRow>
                    <asp:TableCell>Confirmation du mot de passe :</asp:TableCell><asp:TableCell><asp:TextBox ID = "tbMdpConfirm" TextMode = "Password" runat = "server" ValidationGroup="gInscription" /></asp:TableCell><asp:TableCell>
                        <asp:RequiredFieldValidator
                                ID="rfvMdpInscConf"
                                EnableClientScript = "true"
                                ControlToValidate = "tbMdpConfirm"
                                text = "#"
                                ErrorMessage = "Champs obligatoire"
                                Enabled = "true"
                                runat = "server"/>
                    </asp:TableCell></asp:TableRow></asp:Table><asp:Button class="btnValid" ID="validInscription" runat="server" Text="Valider" ValidationGroup="gInscription"/>
                    <asp:ValidationSummary
                ValidationGroup="gInscription"
                HeaderText = "Erreurs de saisie :"
                ID = "vsInscription"
                EnableClientScript = "true"
                DisplayMode = "BulletList"
                runat = "server"
                Width = "400"/>    
        </asp:Panel>
     
    </asp:Content>
    voyez vous un problème? je n' ai rien en code behind

    merci d'avance pour votre aide

  2. #2
    Modérateur
    Avatar de DotNetMatt
    Homme Profil pro
    CTO
    Inscrit en
    Février 2010
    Messages
    3 611
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : CTO
    Secteur : Finance

    Informations forums :
    Inscription : Février 2010
    Messages : 3 611
    Points : 9 743
    Points
    9 743
    Billets dans le blog
    3
    Par défaut
    Il faut que tu rajoutes la propriété ValidationGroup sur chacun de tes validateurs

  3. #3
    Membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Octobre 2008
    Messages
    73
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Octobre 2008
    Messages : 73
    Points : 59
    Points
    59
    Par défaut
    Tout simplement ... pourtant je l' avais mis partout sauf la

    merci beaucoup :p

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MySQL] Formulaire qui ne fonctionne pas
    Par makaphrodite dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 23/05/2009, 13h17
  2. Réponses: 2
    Dernier message: 20/08/2008, 23h09
  3. Réponses: 5
    Dernier message: 14/02/2008, 21h20
  4. Validation formulaire qui ne fonctionne pas
    Par dom59111 dans le forum Langage
    Réponses: 6
    Dernier message: 25/10/2007, 10h18
  5. [MySQL] Un formulaire qui ne fonctionne pas comme il faut (problèmes avec stripslashes & com)
    Par vincent.b dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 30/04/2007, 20h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo