0

I'm adding a field via jquery on a form, tried to add manually the validation and the required tag. But when i click on the field it doesn't show the validation message under the input.

var fieldToAdd='<div class="col-md-12"> ' +
                  '<input class="form-control col-md-10" data-val="true" data-
                   val-required="Le champ Destination est requis." id="' + 
                   personalID + '" name="' + personalID + '" type="text" 
                   value="">' ;

$(".destinationMultiple").append(fieldToAdd);

$("#" + personalID).rules('add', {
                required: true,
                messages: {
                    required:"Ce champ est important"
                }
            })

Edit: It does put the red style surrounding the input in red but not the message under it

tahtoh
  • 102
  • 8
  • According to https://stackoverflow.com/a/3034059/3684265 you need to run validate before adding new rules – imvain2 Feb 07 '19 at 22:50
  • Even adding that doesn't add the message under it, like ive said the red border is visible tho, i don't know if i need to add a span with the error message or something – tahtoh Feb 07 '19 at 22:53

0 Answers0