showing results for - "jquery validation errorplacement"
Assya
08 Feb 2019
1$(document).ready(function () {
2    $('#add_client').validate({
3        errorClass: 'validation_errors',
4        debug: false,
5        rules: {
6            client_name: {
7                required: true
8            },
9            client_address: {
10                required: true
11            },
12            client_city: {
13                required: true
14            }
15        },
16        errorPlacement: function (error, element) {
17            console.log('dd', element.attr("name"))
18            if (element.attr("name") == "client_city") {
19                error.appendTo("#messageBox");
20            } else {
21                error.insertAfter(element)
22            }
23        },
24        messages: {
25            client_name: {
26                required: "The Client name is a required / mandatory field"
27            },
28            client_address: {
29                required: "The Client address is a required / mandatory field"
30            },
31            client_city: {
32                required: "The City is a required / mandatory field"
33            },
34
35        },
36        submitHandler: () => {
37        $('#send_form').on('click', submitFormHandler)
38        $('#send_form').trigger('click')
39        $('#terms-of-use').removeClass("checked")
40        $('#terms').removeClass("checked")
41      }
42    });
43});