I have a field, I have added a regex for it. So this regex does not allow more than 7 digits before decimal and more than two digits after the decimal. this is working fine, it gives an error message properly. Now I want to give different-2 messages for before decimal points and after decimal points. If the user enters more than 7 digits of a numeric value, then the error message will come under the field as “Maximum 7 digits are allowed.” If the user enters more than 2 digits of the decimal value, then the error message will come under field as “Maximum 2 digits of decimals are allowed.”
[RegularExpression("^\\d{0,7}(\\.\\d{0,2})?$", ErrorMessage = "Please enter Comment in the right format.")]
public decimal? decimalField { get; set; }
Edit: Can we do something line like? https://stackoverflow.com/a/4803634/13211840
If not possible in MVC then how is it possible using javascript or jquery?