0

I have created a dynamic html block. When you click on add more button generate three field name, from-date, to-date and i apple the validation on this field but it's not working.

enter image description here Dynamic post fields name :

<input type="text" name="data[User][title][]" />
<input type="text" name="data[User][fromdate][]" />
<input type="text" name="data[User][todate][]" />

Above fields are dynamic generated html and i want to give a validation every new generated field from Jquery Validation but it's not working.

Jquery Validation Rules :

 $(".UserForm").validate({
ignore: "", 
errorElement: 'label',
errorClass: 'error', 
highlight: function(element, errorClass, validClass) {
  $(element).parents("div.form-group").addClass("get-error");
},
unhighlight: function(element, errorClass, validClass) {
  $(element).parents("div.form-group").removeClass("get-error");
},

    rules: {
        "data[User][title][]": {
            required : true, 
        },
        "data[User][fromdate][]": {
            required : true
        },
         "data[User][todate][]": {
            required : true
        }
    },
    messages: {
        "data[User][title][]": {
            required: "Please enter title", 
        },
        "data[User][fromdate][]": {
            required: "Please select fromdate", 
        },
        "data[User][todate][]": {
            required: "Please select todate",
        }  
    }
});
5
  • Any one have answer this question Commented May 28, 2018 at 6:20
  • You need to be more specific than "not working". That's very vague. Provide details about what you expect to happen, what actually happens, any error messages generated (e.g. in the JS console), that sort of thing. Commented May 28, 2018 at 20:37
  • @Greg Schmidt Hello i will post a screen short. what actual i want. Commented May 29, 2018 at 4:05
  • Please check stackoverflow.com/questions/20561712/… Commented May 29, 2018 at 4:51
  • @tarikul05 Its work only one fields Commented May 29, 2018 at 4:57

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.