I am being asked to change the validation message that is displayed to the user during registration.
The site uses the Individual User Accounts
I have modified to add FirstName, LastName, get the phone number at registration and use Captcha
This is what the registration model looks like now
public class RegisterViewModel
{
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
[Required]
[StringLength(50, ErrorMessage = "The {0} can not exceed {1} characters.")]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required]
[StringLength(50, ErrorMessage = "The {0} can not exceed {1} characters.")]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[Required]
[Display(Name = "Telephone"), Phone]
[DataType(DataType.PhoneNumber)]
public string PhoneNumber { get; set; }
public string CaptchaCode { get; set; }
}
and this is what the controller code looks like
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
try
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
// For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
return RedirectToAction("Index", "Home");
}
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}
catch (Exception ex)
{
Errors.ErrorOccured(ex);
}
return View(model);
}
now one of the testers for the company office that sold the product tried to use an email address that they had already used for registration and this image is what they got back for the message on the screen
How do I remove the 1st message that says
Name ******@aol.com is already taken ?