Dear Support,
I have a form with several dropdownlist. I tried to add the "required"default rules, but it does not work.
For instance, this one (a simple input) works perfectly :
When this field is empty and that I try to submit the form, it shows a message for me to fill the field.
however, for this one :
Require does not work. When I submit the form with that field without any value selected, the form doesn't show any message and the form is submitted.
How does the "require" default rule works with a dropdownlist ?
Thank you for your help
Thank you very much for your answer, but it doesnt work exactly.
First of all, when I load the form, it already show an error, whereas I haven't press the submit button yet :
Then, when I press "Ajouter", it show several times "The field is required":
This is not accurate enough.
1/ First, I would like the message to appears just below the field which is concerned,and not beyond the button.
2/ The, instead of "the field", I would like to see for intances " The name is required" => customize the error message.
3/ Then, is it possible to translate in French?
Ps : my form is contained in a modal.
Thank you in advance :)
My code is in the zip file.
|
<div class="error-element">
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12" form-group>
<ejs-textbox
id="name"
required
floatLabelType="Auto"
placeholder="Titre *"
v-model="form.name"
/>
</div>
</div>
<div class="error-element">
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12" form-group>
<ejs-dropdownlist
id="dropdownHorse"
floatLabelType="Auto"
:dataSource="getHorsesList()"
:fields="fields"
placeholder="Cheval concerné *"
v-model="form.horse_id"
/>
</div>
</div>
customPlacement: function (inputelement, errorElement) {
var parentElement = inputelement.closest(".error-element");
parentElement.appendChild(errorElement);
},
|
|
options: {
name: {
required: [true, "The name is required"],
},
dropdownHorse: {
required: [true, "The dropdownHorse is required"],
},
},
locale: "fr",
},
|
|
L10n.load({
fr: {
formValidator: {
required: "Ce champ est requis.",
},
},
});
options: {
customPlacement: function (inputelement, errorElement) {
var parentElement = inputelement.closest(".error-element");
parentElement.appendChild(errorElement);
},
rules: {
name: {
required: true,
},
dropdownHorse: {
required: true,
},
},
locale: "fr",
},
};
|
Thank you very much, it works perfectly :)