@using (Html.BeginForm(actionName: "Create", controllerName: "Employee", method: FormMethod.Post, htmlAttributes: new { enctype = "multipart/form-data", @id = "form-horizontal", @class = "form-horizontal form-wizard-wrapper text-right form-parsley" } )) { <div class="col-md-6"> <div class="form-group row"> <label for="txtAddress2Billing" class="col-lg-3 col-form-label">Code</label> <div class="col-lg-8 form-group" id="classcode"> @Html.EditorFor(model => model.code, new { htmlAttributes = new { @type = "Text", @class = " form-control", @id = "Code", @oninput = "CodeCheck()" } }) @Html.ValidationMessageFor(model => model.code, "", new { @class = "text-danger" }) </div> <p id="Status" class="col-lg-1 mt-2" /> </div><!--end form-group--> </div><!--end col--> <div class="form-group row"> <div class="col-lg-2"></div> <div class="col-lg-3"> <input type="submit" value="Create" class="btn btn-outline-warning" style="width:150px;" /> </div> <div class="col-lg-3"> <a href="~/EmpDatas/Index" class="btn btn-outline-warning" style="width:150px"> Cancel</a> </div> </div> } <script src="~/assets/js/jquery.min.js"></script> <script src="~/assets/js/bootstrap.bundle.min.js"></script> <script src="~/assets/js/app.js"></script> <script> function CodeCheck() { $("#Status").html('<i class="fas fa-spinner fa-pulse"></i>'); $.post("@Url.Action("CheckCodeAvailability", "Employee")", { Code: $("#Code").val() }, function (data) { if (data == 0) { $("#Status").html('<i class="far fa-times-circle text-danger"></i>'); $("#Code").css("border-color", "Red"); } else { $("#Status").html('<i class="far fa-check-circle text-success"></i>'); $("#Code").css("border-color", "Green"); } }); } </script>and This is my Json code
public JsonResult CheckCodeAvailability(string Code) { System.Threading.Thread.Sleep(200); var exist = db.EmpDatas.Where(m => m.code.ToString() == Code).Count(); if (exist < 1) { return Json(1); } else { return Json(0); } }
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE