How do I execute a function inside JSON?
Hello all,
I'm having a hard time executing a function inside JSON.
JSON code:
- var lsmsValidate =
- {
- 'rules' :
- [
- {
- 'alias' : 'required',
- }
- ],
- 'messages' :
- [
- {
- 'alias' : 'Please type an alias!'
- }
- ],
- 'errorPlacement' :
- [
- function (element)
- {
- $(this.messages.element).appendTo("label[for=" + element + "]");
- }
- ]
-
- };
Code to execute errorPlacement function:
- $('#addlivestock :input:not(:disabled, :button, :submit, :reset)').each(function(){
- if ($(this, ':input:not(:radio)').val() == "")
- {
-
- var getAttr = $(this).attr("name");
- alert(getAttr);
-
- errElements[countElement] = this;
- countElement++;
-
-
- }
- )};
I'm attempting to execute the errorPlacement function inside lsmsValidate with lsmsValidate.errorPlacement(this); It's not working as expected and the error message I'm receiving is: lsmsValidate.errorPlacement is not a function
How do I execute the errorPlacement function inside the lsmsValidate JSON?
Thank You,
Rich