Bonjour.

J'essaie de refaire une partie de l'ergonomie de mon site internet. J'essaie d'utiliser les fonctionnalité avancées de jquery.validate.

Jusqu'ici, je faisais apparaitre les messages d'erreur avec ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
@Html.ValidationMessageFor(model => model.mavariable)
Cependant, à mon boulot tout le monde trouve ça horrible, moi y compris.
Alors j'aimerais faire apparaitre les message d'erreur dans les placeholder.
Voici mes extraits de code.

javascript :
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
$(function () {
 
    var Company_Autocomplete = $("input[type=text]#Company");
    var Company_Hidden = $("input[type=hidden]#Company_CompanyID");
    var Company_AddButton = $("button#AddCompanyButton");
    var Company_ResetButton = $("button#ResetCompanyButton");
    var Company_CreationForm = $("div#AddCompanyForm");
    var Civiliy_Checkbox = $("#Civility");
 
    Company_Autocomplete.autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/" + _Culture + "/Company/GetList",
                type: "POST",
                dataType: "json",
                success: function (Companies) {
                    response($.map(Companies, function (Company) {
                        return { label: Company.CompanyName, value: Company.CompanyName, id: Company.CompanyID };
                    }));
                }
            });
        },
        select: function (event, ui) {
            Company_Hidden.val(ui.item.id);
        },
        open: function () {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function () {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
    });
 
    Company_CreationForm.hide();
 
    Company_AddButton.button({ icons: { primary: "ui-icon-plus" }, text: false })
                        .click(function () {
                            $(this).hide();
                            Company_ResetButton.show();
                            Company_Autocomplete.attr("disabled", true).autocomplete({ disabled: true }).val("");
                            Company_Hidden.val("");
                            Company_CreationForm.show("blind", {}, 1000);
                        });
 
    Company_ResetButton.button({ icons: { primary: "ui-icon-cancel" }, text: false })
                        .hide()
                        .click(function () {
                            $(this).hide();
                            Company_AddButton.show();
                            Company_Autocomplete.attr("disabled", false).autocomplete({ disabled: false });
                            Company_CreationForm.hide("blind", {}, 1000);
                        });
 
    Civiliy_Checkbox.buttonset();
 
});
ma vue :
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
@model LivDevis.Models.CustomerModel
 
@using LivDevis.Helpers
@using LivDevis.Models
 
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Authentificated/Layout.cshtml";
 
    List<CountryModel> Countries = ViewBag.Countries;
    List<CultureModel> Cultures = ViewBag.Cultures;
}
 
@section css {
    @Styles.Render("~/Content/_Authentificated/Customer/Create")
}
 
@section jquery {
    @Scripts.Render("~/bundles/jqueryval")
}
 
@section Scripts {
    @Scripts.Render("~/bundles/_Authentificated/Customer/Create")
}
 
@section featured {
 
}
 
<section id="info">
    @using (Html.BeginForm("Create", "Customer", FormMethod.Post, new { autocomplete = "off", @id = "CreateCustomer" })) {
        @Html.ValidationSummary(true)
 
        <fieldset>
            <legend>Sélectionner une société</legend>
 
            <div class="editor-field">
                @Html.TextBox("Company", null, new { PlaceHolder = LivDevis.Resources.Models.AccountModel.DisplayCompany })
                @Html.HiddenFor(model => model.Company.CompanyID)
                <button id="AddCompanyButton" class="action"></button>
                <button id="ResetCompanyButton" class="action"></button>
            </div>
        </fieldset>
 
        <div id="AddCompanyForm">
            <fieldset>
                <legend>Ajouter les informations sur la société</legend>
 
                <article>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.CompanyName, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayCompanyName })
                        @*@Html.ValidationMessageFor(model => model.Company.CompanyName)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.Address1, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayAddress1 })
                        @*@Html.ValidationMessageFor(model => model.Company.Address1)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.Address2, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayAddress2 })
                        @*@Html.ValidationMessageFor(model => model.Company.Address2)*@
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.Address3, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayAddress3 })
                        @*@Html.ValidationMessageFor(model => model.Company.Address3)*@
                    </div>
                </article>
 
                <article>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.Company.Country)
                    </div>
                    <div class="editor-field">
                        @Html.DropDownListFor(model => model.Company.CountryID, new SelectList(Countries, "CountryID", "Flag", null))
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBox("Localization", null, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayLocalization })
                        @Html.HiddenFor(model => model.Company.LocalizationID)
                        @*@Html.ValidationMessageFor(model => model.Company.Localization)*@
                    </div>
                </article>
            </fieldset>
 
            <fieldset>
                <legend>Ajouter les informations complémentaires</legend>
 
                <article>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.Type, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayType })
                        @*@Html.ValidationMessageFor(model => model.Company.Type)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.ShareCapital, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayShareCapital })
                        @*@Html.ValidationMessageFor(model => model.Company.ShareCapital)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.TVANumber, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayTVANumber })
                        @*@Html.ValidationMessageFor(model => model.Company.TVANumber)*@
                    </div>
                </article>
 
                <article>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.Siret, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplaySiret })
                        @*@Html.ValidationMessageFor(model => model.Company.Siret)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.NafCode, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayNafCode })
                        @*@Html.ValidationMessageFor(model => model.Company.NafCode)*@
                    </div>
 
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.Company.RCS, new { PlaceHolder = LivDevis.Resources.Models.CompanyModel.DisplayRCS })
                        @*@Html.ValidationMessageFor(model => model.Company.RCS)*@
                    </div>
                </article>
            </fieldset>
        </div>
 
        <fieldset>
            <legend>Ajouter les informations sur le client</legend>
 
            <article>
                <div class="editor-field">
                    <div id="Civility">
                    @{
                        int i = 0;
                        foreach (Enum c in Enum.GetValues(typeof(Civility)))
                        {
                            string _id = string.Concat("civility-", c);
                            string _description = c.Description();
 
                            switch (i == 0)
                            {
                                case true:
                                    @Html.RadioButtonFor(model => model.Civility, c, new { id = _id, @checked = "checked" })
                                break;
 
                                case false:
                                    @Html.RadioButtonFor(model => model.Civility, c, new { id = _id })
                                break;
                            }
 
                            @Html.LabelFor(model => model, _description, new { @for = _id })
                            i++;
                        }
                    }
                    </div>
                </div>
 
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.FirstName, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayFirstName })
                    @*@Html.ValidationMessageFor(model => model.FirstName)*@
                </div>
 
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.LastName, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayLastName })
                    @*@Html.ValidationMessageFor(model => model.LastName)*@
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.Email, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayEmail })
                    @*@Html.ValidationMessageFor(model => model.Email)*@
                </div>
 
                <div class="editor-field">
                    @Html.PasswordFor(model => model.Password, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayPassword })
                    @*@Html.ValidationMessageFor(model => model.Password)*@
                </div>
            </article>
 
            <article>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.Phone, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayPhone })
                    @*@Html.ValidationMessageFor(model => model.Phone)*@
                </div>
 
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.MobilePhone, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayMobilePhone })
                    @*@Html.ValidationMessageFor(model => model.MobilePhone)*@
                </div>
 
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.Fax, new { placeholder = LivDevis.Resources.Models.AccountModel.DisplayFax })
                    @*@Html.ValidationMessageFor(model => model.Fax)*@
                </div>
 
                <div class="editor-label">
                    @Html.LabelFor(model => model.Culture)
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(model => model.Culture.CultureID, new SelectList(Cultures, "CultureID", "CultureID", null))
                </div>
            </article>
 
            <p>
                <input type="submit" value="@LivDevis.Resources.Views.Account.SignUp.ButtonCreateAccount" class="button blue" />
            </p>
        </fieldset>
    }
</section>
Après une petite recherche google, j'ai trouvé le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
$("form").validate({
        errorPlacement: function (error, element) {
            alert("Hello World !");
            //element.attr("placeholder", error);
        }
    });
mais je n'arrive même pas à faire un Hello World :/.

Comment poursuivre ? Merci .