Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery password validation
    primarykey
    data
    text
    <p>On my view i have 2 password fields:</p> <pre><code> @Html.PasswordFor(m =&gt; m.Password)&lt;br /&gt; @Html.PasswordFor(m =&gt; m.ConfirmPassword)&lt;br /&gt; </code></pre> <p>Now i am looking for a way to use my javascript function below on these two fields. </p> <pre><code>function addCustomMessages() { $("#password_confirm").rules("add", { required: true, equalTo: "#password", messages: { required: "Herhaal uw wachtwoord", equalTo: "Enter the same password as above" } }); } </code></pre> <p>How can i tell <code>@Html.PasswordFor(m =&gt; m.ConfirmPassword)</code> it needs t use <code>#password-confirm</code></p> <p><strong>EDIT:</strong></p> <p>View:</p> <pre><code> @Html.PasswordFor(m =&gt; m.Password, new { @id="password", @class = "equalTo" })&lt;br /&gt; @Html.PasswordFor(m =&gt; m.ConfirmPassword, new { @id="password_confirm", @class = "equalTo" })&lt;br /&gt; </code></pre> <p>Javascript:</p> <pre><code>/* * Translated default messages for the jQuery validation plugin. * Locale: NL (Dutch; Nederlands, Vlaams) */ (function ($) { $.extend($.validator.messages, { required: "Dit is een verplicht veld.", remote: "Controleer dit veld.", email: "Vul hier een geldig e-mailadres in.", url: "Vul hier een geldige URL in.", date: "Vul hier een geldige datum in.", dateISO: "Vul hier een geldige datum in (ISO-formaat).", number: "Vul hier een geldig getal in.", digits: "Vul hier alleen getallen in.", creditcard: "Vul hier een geldig creditcardnummer in.", equalTo: "Vul hier dezelfde waarde in.", accept: "Vul hier een waarde in met een geldige extensie.", maxlength: $.validator.format("Vul hier maximaal {0} tekens in."), minlength: $.validator.format("Vul hier minimaal {0} tekens in."), rangelength: $.validator.format("Vul hier een waarde in van minimaal {0} en maximaal {1} tekens."), range: $.validator.format("Vul hier een waarde in van minimaal {0} en maximaal {1}."), max: $.validator.format("Vul hier een waarde in kleiner dan of gelijk aan {0}."), min: $.validator.format("Vul hier een waarde in groter dan of gelijk aan {0}."), // for validations in additional-methods.js iban: "Vul hier een geldig IBAN in.", dateNL: "Vul hier een geldige datum in.", phoneNL: "Vul hier een geldig Nederlands telefoonnummer in.", mobileNL: "Vul hier een geldig Nederlands mobiel telefoonnummer in.", postalcodeNL: "Vul hier een geldige postcode in.", bankaccountNL: "Vul hier een geldig bankrekeningnummer in.", giroaccountNL: "Vul hier een geldig gironummer in.", bankorgiroaccountNL: "Vul hier een geldig bank- of gironummer in." }); function addCustomMessages() { $("#password_confirm").rules("add", { required: true, equalTo: "#password", messages: { required: "Herhaal uw wachtwoord", equalTo: "Enter the same password as above" } }); } }(jQuery)); </code></pre> <p>still not working for me, someone who can help me with it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload