Skip to content

Commit 109e026

Browse files
author
daffl
committed
Merge github.com:daffl/jquery.dform
2 parents 38ff492 + 7c6db53 commit 109e026

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

src/dform.extensions.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,21 +541,63 @@
541541
}
542542
};
543543
}
544+
if (typeof (options.validate) == 'object')
545+
$.extend(defaults, options.validate);
544546
this.validate(defaults);
545547
}
546548
},
547549
/**
548550
* subscriber: validate
549551
*
550552
* Adds support for the jQuery validation rulesets.
553+
* For types: <text>, <password>, <textarea>, <radio>, <checkbox> sets up rules through rules("add", rules) for validation plugin
554+
* For type <form> sets up as options object for validate method of validation plugin
555+
* For rules of types <checkboxes> and <radiobuttons> you should use this subscriber for type <form> (to see example below)
551556
*
552-
* Parameters:
553-
* options - Options as specified in the rules parameter
554-
* type - The type of the *this* element
557+
* Example:
558+
* validations for radiobuttons group and for text field:
559+
*
560+
* (start code)
561+
* {
562+
* "type" : "form",
563+
* "validate" :
564+
* {
565+
* "rules" :
566+
* {
567+
* "radio_group": "required"
568+
* }
569+
* },
570+
* "elements" :
571+
* [
572+
* {
573+
* "type" : "radiobuttons",
574+
* "caption" : "You should choose from here"
575+
* "name" : "radio_group",
576+
* "options" :
577+
* {
578+
* "Y" : "Yes",
579+
* "N" : "No"
580+
* }
581+
*
582+
* },
583+
* {
584+
* "type" : "text",
585+
* "name" : "url",
586+
* "validate" :
587+
* {
588+
* "required" : true,
589+
* "url" : true
590+
* }
591+
* }
592+
*
593+
* ]
594+
* }
595+
* (end)
555596
*/
556597
"validate" : function(options, type)
557598
{
558-
this.rules("add", options);
599+
if (type != "form")
600+
this.rules("add", options);
559601
}
560602
});
561603

0 commit comments

Comments
 (0)