[Ext.Net.Mvc v3.2.1] Compare password issue

  1. #1

    [Ext.Net.Mvc v3.2.1] Compare password issue

    Hello,

    It seems that the password validation is not working. Code below.

    using System;
    using System.ComponentModel.DataAnnotations;
    
    namespace ExtNetTest.Test.Models
    {
        public class ChangePasswordModel
        {
            [Required]
            [DataType(DataType.Password)]
            public string Password { get; set; }
    
            [DataType(DataType.Password)]
            [Compare("Password", ErrorMessage = "Not valid")]
            public string ConfirmPassword { get; set; }
        }
    }
    using System.Web.Mvc;
    using Ext.Net;
    using Ext.Net.MVC;
    using ExtNetTest.Test.Models;
    using System.Collections.Generic;
    
    namespace ExtNet.Test.Controllers
    {
        public class ExtNetController : Controller
        {
            public ActionResult Index()
            {
                return this.View();
            }
    
            public ActionResult Submit(ChangePasswordModel model)
            {
                return this.FormPanel(ModelState);
            }
        }
    }
    @model ExtNetTest.Test.Models.ChangePasswordModel
    
    @{
        Layout = null;
        
        var X = Html.X();
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Test</title>
    </head>
    <body>
        @(Html.X().ResourceManager().Theme(Theme.CrispTouch).ScriptMode(Ext.Net.ScriptMode.Debug))
    
    
    @(X.FormPanel()
        .Url(Url.Action("Submit"))
        .Width(500)
        .Height(500)
        .Layout("vbox")
        .Items(
            X.TextFieldFor(m => m.Password, false),
            X.TextFieldFor(m => m.ConfirmPassword, false)
        )
        .Buttons(
            X.Button()
                .Text("Submit")
                .Handler("this.up('form').getForm().submit();")
        )
    )
    </body>
    </html>
  2. #2
    Hi Yury,

    Password validation requires a initialPassField setting like that:
    X.TextFieldFor(m => m.Password, false).ID("Password"),
    X.TextFieldFor(m => m.ConfirmPassword, false)
        .CustomConfig(cc => cc.Add(new ConfigItem("initialPassField", "Password")))
    I have two thoughts on possible improvements:

    1. If a TextField has no initialPassField setting, then it would search a TextField sibling (a previous TextField) and use it as initialPassField. It would be implemented in JavaScript.

    2. Maybe, there is a possibility to tie an initialPassField basing on a Compare attribute.

    Logged in GitHub:
    https://github.com/extnet/Ext.NET/issues/1212

    Maybe, at some point we'll be able to have a closer look at it and implement.

Similar Threads

  1. [CLOSED] Password fields TextField saves the password
    By ucaneto in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 29, 2014, 3:38 PM
  2. [CLOSED] compare validate in password not work in master page.
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 09, 2014, 1:40 PM
  3. Implement a Password Meter to a Password Field
    By sudantha in forum 1.x Help
    Replies: 1
    Last Post: Jan 15, 2012, 6:59 AM
  4. Compare values from 2 TimeFields
    By AlexMaslakov in forum 1.x Help
    Replies: 5
    Last Post: Sep 14, 2011, 1:08 PM
  5. Compare Validator
    By Rod in forum 1.x Help
    Replies: 0
    Last Post: Oct 30, 2008, 9:50 AM

Posting Permissions