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

2
  • According to stackoverflow.com/a/3034059/3684265 you need to run validate before adding new rules Commented Feb 7, 2019 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 Commented Feb 7, 2019 at 22:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.