If you use jquery-validate.js library (https://jqueryvalidation.org/), you can also use js to do this job.
See my html part:
<input type="text" id="TBBusquedaDescripcionCategoriaEd" name="TBBusquedaDescripcionCategoriaEd" maxlength="300" class="form-control" required>
Then in js:
var validator = $("#formName").validate({
rules: {
TBBusquedaDescripcionCategoriaEd: {
required: true,
minlength: 4
}
},
messages: {
TBBusquedaDescripcionCategoriaEd: {
required: "Mandatory field custom msg",
minlength: "Minleght custom msg"
}
},
submitHandler: function (form) {...});