Hi Frnds
i created Reg Form With Validation..this is working fine also..
in this form i added one textbox at run time...if i will get a error on a form that time it is showing..
and after filling the data if i will submit this form so text box is showing then gone..
i want to know that y it is showing then gone..
Model///
public class Employee
{
//[Required(ErrorMessage = "Name is Required")]
[Required]
[Display(Name = "Name")]
//[RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "Name should be accept Char only")]
[RegularExpression(@"^.{6,10}$", ErrorMessage = "Name should be of minimum 6 and maximum 10 characters")]
public string Name { get; set; }
[Required(ErrorMessage = "Email is Required")]
[Display(Name = "Email")]
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
ErrorMessage = "Email is not valid")]
public string Email { get; set; }
[Required(ErrorMessage = "Password is Required")]
[Display(Name = "Password")]
[RegularExpression(@"^(?=.*\d)(?=.*[a-zA-Z]).{4,8}$", ErrorMessage = "Password Should be contain atleast 1 Upper, 1 Lower and 1 number")]
//Password Should be contain atleast 1 Upper, 1 Lower and 1 Special Character
public string Password { get; set; }
}
Controller///
public class EmployeeRegFormController : Controller
{
// GET: EmployeeRegForm
public ActionResult Index()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(Employee model)
{
if (ModelState.IsValid)
{
ViewBag.Name = model.Name;
ViewBag.Email = model.Email;
ViewBag.Password = model.Password;
}
if(model.Name == null)
{
ModelState.AddModelError("", "Details is incorrect!");
}
return View(model);
}
}
Index/view/
@if (ViewData.ModelState.IsValid)
{
if (@ViewBag.Name != null)
{
Name : @ViewBag.Name
Email : @ViewBag.Email
}
}
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
}
Bikesh SrivastavaPosted Aug 30, 2016, 6:55 AM
Midhun TpPosted Aug 30, 2016, 5:43 AM
{
if (count <= 1) {
var div = document.createElement('DIV');
div.innerHTML = GetDynamicTextBox("");
document.getElementById("TextBoxContainer").appendChild(div);
}
}
Vinay SinghPosted Aug 30, 2016, 2:41 AM
Anjali KhanPosted Aug 30, 2016, 1:36 AM
thanks for the update..but please chk again if i click on registered button textbox is coming for the second and gone.
but i want should not be apper when i registered with valid details..it i not apper but for the second it came..so how to solve this problem
Jinish GandhiPosted Aug 30, 2016, 1:29 AM
Anjali KhanPosted Aug 30, 2016, 1:16 AM
Jinish GandhiPosted Aug 30, 2016, 1:13 AM
Anjali KhanPosted Aug 30, 2016, 12:59 AM
Jinish GandhiPosted Aug 30, 2016, 12:56 AM