Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

I have a problem about "Compare"

$
0
0

Hi,

I have a problem about "Compare" (password and ConfirmPassword). if I use it, Page can be post but record is not possible. 

if remove just it that compare, page is ok. I am new about mvc and core 2.0 and my project is core 2.0 

can you see any problem ? 

Model:

        [Required]
        [DataType(DataType.Password)]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 8)]
        [Display(Name = "Password")]
        [RegularExpression("^((?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])|(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^a-zA-Z0-9])|(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])).{8,}$", ErrorMessage = "Passwords must be at least 8 characters and contain at 3 of 4 of the following: upper case (A-Z), lower case (a-z), number (0-9) and special character (e.g. !@#$%^&*)")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The passwords do not match.")]
        public string ConfirmPassword { get; set; }

HomeController

        [HttpPost]
        public ActionResult Register(Kullanicilar kullanicilar)
        {

            kullanicilar.CreatedDate = DateTime.Now;
            kullanicilar.CreatedUserId = 0;
            kullanicilar.UpdatedDate = DateTime.Now;
            kullanicilar.UpdatedUserId = 0;

            kullanicilar.Ip = "127.0.0.1"; //HttpContext.Connection.RemoteIpAddress.ToString();
            kullanicilar.Session = "SESSIONBURAYA";

            kullanicilar.Tarayici = "TARAYICI";
            kullanicilar.CariKodu = "CARI KODU";

            if (ModelState.IsValid)
            {

                _context.Kullanicilar.Add(kullanicilar);
                _context.SaveChanges();

                ModelState.Clear();
                ViewBag.Message = kullanicilar.Adi + " " + kullanicilar.Soyadi + " kaydınız tamamlandı.";

            }
            return View();
        }

MVC View Page


@model PosSistem.Database.Tablolar.Kullanicilar

@{
ViewData["Title"] = "Kullanıcı Kayıt";
}

<h2>Kullanıcı Kayıt</h2>
<div class="form-horizontal">
<form asp-controller="Home" asp-action="Register" method="post">
@if (ViewBag.Message != null)
{
<div class="form-control">
<div class="col-md-10">@ViewBag.Message</div>
</div>

}
<div class="form-group">
<label asp-for="Adi" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Adi" class="form-control" />
<span asp-validation-for="Adi"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Soyadi" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Soyadi" class="form-control" />
<span asp-validation-for="Soyadi"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Eposta" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Eposta" class="form-control" />
<span asp-validation-for="Eposta"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password"></span>
</div>
</div>
<div class="form-group">
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Cep" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Cep" class="form-control" />
<span asp-validation-for="Cep"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Tarayici" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Tarayici" class="form-control" />
<span asp-validation-for="Tarayici"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Ip" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="Ip" class="form-control" />
<span asp-validation-for="Ip"></span>
</div>
</div>
<div class="form-group">
<label asp-for="PicturedId" class="col-md-2 control-label"></label>
<div class="col-md-4">
<input asp-for="PicturedId" class="form-control" />
<span asp-validation-for="PicturedId"></span>
</div>
</div>

<div class="form-group">
<button type="submit" class="btn btn-default">Kayıt</button>
</div>
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
</form>

</div>


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>