Hello Team,
Am trying to apply a textfield validation in my code but is not working, please assist. thanks
@Html.TextBoxFor(model => model.FinalPay, new { @class = "form-control", @name = "finalsalary", @id = "finalsalary", @placeholder = "Enter Final Pay" })
@Html.ValidationMessageFor(model => model.FinalPay, "", new { @class = "text-danger" })
MODEL CLASS
[Display(Name = "FinalPay")]
[Required(ErrorMessage = "Final pay is required.")]
Vishal JoshiPosted Nov 5, 2023, 6:13 AM
Hello Emmanuel,
You need to call Jquey for validation before submitting the form if you are using ajax call. please try the below code.
Also, make sure you have added the jQuery validation reference properly in the header part of the page or globally. check the below references.
Thank you
Vishal Joshi
Emmmanuel FIADUFEPosted Nov 5, 2023, 11:03 AM
Thank you Vishal and Kumar it is working now
Emmmanuel FIADUFEPosted Nov 5, 2023, 11:00 AM
Thank you Team and Vishal for your support, it is working now as Vishal said
Jignesh KumarPosted Nov 5, 2023, 5:11 AM
Hello emmanuel,
If you want enalbe client side data annotation in mvc application then you need to refer below list of jquery to your page,
Rupesh KahanePosted Nov 5, 2023, 3:21 AM
Refer below article
https://www.c-sharpcorner.com/UploadFile/a8024d/validation-using-data-annotations-in-Asp-Net-mvc-5/
Emmmanuel FIADUFEPosted Nov 4, 2023, 9:39 PM
Hello Vishal, it's not working
Vishal YelvePosted Nov 4, 2023, 11:43 AM
Hi
Try to add below JQuery on ur page.