[StringLength] Data Annotations for Model Validation Not Working in ejs-for

[StringLength]

ejs-for not rendering same html as asp-for renders .

asp-for Data Annotation [StringLength] add maxstringlength attribute for text input field 

where ejs-for ​does not 

Is there any work around to get same html output 


1 Reply 1 reply marked as answer

UD UdhayaKumar Duraisamy Syncfusion Team June 18, 2023 08:56 AM UTC

Based on the information you have shared, we suspect that you are attempting to use validation for the MaxLength character limit in the TextBoxFor component. To achieve this, you can use the MaxLength attribute. For further details, please refer to the following code snippet.


public class TextBoxValue

    {

        [Required(ErrorMessage = "Value is required")]

        [MaxLength(5, ErrorMessage = "Maximum length is 5 characters")]

        public string firstname { get; set; }

    }



Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/TextBoxFor-762520295



Marked as answer
Loader.
Up arrow icon