|
732 | 732 | checkValues: function (val, iCol, customobject, nam, options) {
|
733 | 733 | var edtrul, nm, dft, g = this, p = g.p, colModel = p.colModel, cm, isEmpty = jgrid.isEmpty,
|
734 | 734 | editMsg = getGridRes.call($(g), "edit.msg"), ret,
|
| 735 | + getPropertyValue = function (propertyName) { |
| 736 | + var propValue = edtrul[propertyName]; |
| 737 | + return $.isFunction(propValue) ? propValue.call(g, options) : propValue; |
| 738 | + }, |
735 | 739 | dateMasks = getGridRes.call($(g), "formatter.date.masks");
|
736 | 740 | if (customobject === undefined) {
|
737 | 741 | if (typeof iCol === "string") {
|
|
750 | 754 | }
|
751 | 755 | if (edtrul) {
|
752 | 756 | if (!nm) { nm = p.colNames != null ? p.colNames[iCol] : cm.label; }
|
753 |
| - if (edtrul.required === true) { |
| 757 | + if (getPropertyValue("required") === true) { |
754 | 758 | if (isEmpty(val)) { return [false, nm + ": " + editMsg.required, ""]; }
|
755 | 759 | }
|
756 | 760 | // force required
|
757 |
| - var rqfield = edtrul.required === false ? false : true; |
758 |
| - if (edtrul.number === true) { |
| 761 | + var rqfield = getPropertyValue("required") === false ? false : true; |
| 762 | + if (getPropertyValue("number") === true) { |
759 | 763 | if (!(rqfield === false && isEmpty(val))) {
|
760 | 764 | if (isNaN(val)) { return [false, nm + ": " + editMsg.number, ""]; }
|
761 | 765 | }
|
|
767 | 771 | if (parseFloat(val) > parseFloat(edtrul.maxValue)) { return [false, nm + ": " + editMsg.maxValue + " " + edtrul.maxValue, ""]; }
|
768 | 772 | }
|
769 | 773 | var filter;
|
770 |
| - if (edtrul.email === true) { |
| 774 | + if (getPropertyValue("email") === true) { |
771 | 775 | if (!(rqfield === false && isEmpty(val))) {
|
772 | 776 | // taken from $ Validate plugin
|
773 | 777 | filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
774 | 778 | if (!filter.test(val)) { return [false, nm + ": " + editMsg.email, ""]; }
|
775 | 779 | }
|
776 | 780 | }
|
777 |
| - if (edtrul.integer === true) { |
| 781 | + if (getPropertyValue("integer") === true) { |
778 | 782 | if (!(rqfield === false && isEmpty(val))) {
|
779 | 783 | if (isNaN(val)) { return [false, nm + ": " + editMsg.integer, ""]; }
|
780 | 784 | if ((val % 1 !== 0) || (val.indexOf(".") !== -1)) { return [false, nm + ": " + editMsg.integer, ""]; }
|
781 | 785 | }
|
782 | 786 | }
|
783 |
| - if (edtrul.date === true) { |
| 787 | + if (getPropertyValue("date") === true) { |
784 | 788 | if (!(rqfield === false && isEmpty(val))) {
|
785 | 789 | if (cm.formatoptions && cm.formatoptions.newformat) {
|
786 | 790 | dft = cm.formatoptions.newformat;
|
|
793 | 797 | if (!jgrid.checkDate(dft, val)) { return [false, nm + ": " + editMsg.date + " - " + dft, ""]; }
|
794 | 798 | }
|
795 | 799 | }
|
796 |
| - if (edtrul.time === true) { |
| 800 | + if (getPropertyValue("time") === true) { |
797 | 801 | if (!(rqfield === false && isEmpty(val))) {
|
798 | 802 | if (!jgrid.checkTime(val)) { return [false, nm + ": " + editMsg.date + " - hh:mm (am/pm)", ""]; }
|
799 | 803 | }
|
800 | 804 | }
|
801 |
| - if (edtrul.url === true) { |
| 805 | + if (getPropertyValue("url") === true) { |
802 | 806 | if (!(rqfield === false && isEmpty(val))) {
|
803 | 807 | filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
|
804 | 808 | if (!filter.test(val)) { return [false, nm + ": " + editMsg.url, ""]; }
|
|
0 commit comments