Reputation: 3642
I am trying to validate a field "organization.mailDomain"
with jquery form validation plugin. My rules for validation are
rules : {
"organization.name" : {
required : true
},
"organization.mailDomain" : {
required : true,
remote : {
url : "/domain/check",
type : "post",
contentType : "application/json",
data : {mailDomain : $("#mailDomain").val()}
}
}
what i want is to send data as mailDomain=gmail.com
but my current code is sending data as organization.mailDomain=abc.com&mailDomain=gmail.com
.
I know if i change field name from (organization.mailDomain
) to (mailDomain
) it will work, but i need the field name as it is.
UPDATE : By default the value is "gmail.com" but when i change the value to "abc.com" the post data is organization.mailDomain=abc.com&mailDomain=gmail.com
UPDATE : i am getting following error on server side
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('o' (code 111)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
can any one kindly help me?????
Upvotes: 1
Views: 662
Reputation: 388316
In order to pass dynamic data to the remote function, you can pass a function as the data value, which will return the desired value... this function will get evaluated whenever the validator is called
remote: {
url: "/domain/check",
type: "post",
contentType: "application/json",
data: {
mailDomain: function () {
return $("#mailDomain").val()
}
}
}
Upvotes: 1