Changeset 994

Show
Ignore:
Timestamp:
06/18/08 00:33:58 (6 months ago)
Author:
laurentj
Message:

jforms: worked on <choice> implementation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js

    r985 r994  
    8585    }, 
    8686 
    87  
    8887    getValue : function (elt){ 
    8988        var value=''; 
    9089        if(elt.nodeType) { // this is a node 
    9190            switch (elt.nodeName.toLowerCase()) { 
    92                 case "input": 
    93                     switch (elt.getAttribute("type")) { 
    94                     case "checkbox": 
    95                     case "radio": 
    96                         if (elt.checked) 
    97                             value = 'true'; 
    98                         else 
    99                             value = 'false'; 
    100                         break; 
    101                     default: 
    102                         value = elt.value; 
    103                         break; 
     91            case "input": 
     92                switch (elt.getAttribute("type")) { 
     93                case "checkbox": 
     94                case "radio": 
     95                    if (elt.checked) 
     96                        value = 'true'; 
     97                    else 
     98                        value = 'false'; 
     99                    break; 
     100                default: 
     101                    value = elt.value; 
     102                    break; 
     103                } 
     104                break; 
     105            case "textarea": 
     106                value= elt.value; 
     107                break; 
     108            case "select": 
     109                if (!elt.multiple) { 
     110                    value =  elt.value; 
     111                    break; 
     112                } 
     113                var options = elt.getElementsByTagName("option"); 
     114                value = []; 
     115                for (var i = 0; i < options.length; i++) { 
     116                    if (options[i].selected) { 
     117                        value.push(options[i].value); 
    104118                    } 
    105                     break; 
    106                 case "textarea": 
    107                     value= elt.value; 
    108                     break; 
    109                 case "select": 
    110                     if (!elt.multiple) { 
    111                         value =  elt.value; 
    112                         break; 
    113                     } 
    114                     var options = elt.getElementsByTagName("option"); 
    115                     value = []; 
    116                     for (var i = 0; i < options.length; i++) { 
    117                         if (options[i].selected) { 
    118                             value.push(options[i].value); 
    119                         } 
    120                     } 
    121                     break; 
     119                } 
     120                break; 
    122121            } 
    123122        } else if(elt.item){ 
     
    194193    this.maxLength = -1; 
    195194}; 
    196 jFormsControlString.prototype.check = function (val) { 
     195jFormsControlString.prototype.check = function (val, jfrm) { 
    197196    if(this.minLength != -1 && val.length < this.minLength) 
    198197        return false; 
     
    241240}; 
    242241 
    243  
    244  
    245242/** 
    246243 * control with boolean 
     
    254251    this.help=''; 
    255252}; 
    256 jFormsControlBoolean.prototype.check = function (val) { 
     253jFormsControlBoolean.prototype.check = function (val, jfrm) { 
    257254    return (val == 'true' || val == 'false'); 
    258255}; 
     
    269266    this.help=''; 
    270267}; 
    271 jFormsControlDecimal.prototype.check = function (val) { 
     268jFormsControlDecimal.prototype.check = function (val, jfrm) { 
    272269    return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 
    273270}; 
     
    284281    this.help=''; 
    285282}; 
    286 jFormsControlInteger.prototype.check = function (val) { 
     283jFormsControlInteger.prototype.check = function (val, jfrm) { 
    287284    return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 
    288285}; 
     
    299296    this.help=''; 
    300297}; 
    301 jFormsControlHexadecimal.prototype.check = function (val) { 
     298jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 
    302299  return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 
    303300}; 
     
    314311    this.help=''; 
    315312}; 
    316 jFormsControlDatetime.prototype.check = function (val) { 
     313jFormsControlDatetime.prototype.check = function (val, jfrm) { 
    317314    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 
    318315    if(t == null) return false; 
     
    343340    this.help=''; 
    344341}; 
    345 jFormsControlDate.prototype.check = function (val) { 
     342jFormsControlDate.prototype.check = function (val, jfrm) { 
    346343    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 
    347344    if(t == null) return false; 
     
    367364    this.help=''; 
    368365}; 
    369 jFormsControlTime.prototype.check = function (val) { 
     366jFormsControlTime.prototype.check = function (val, jfrm) { 
    370367    var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 
    371368    if(t == null) return false; 
     
    394391    this.lang=''; 
    395392}; 
    396 jFormsControlLocaledatetime.prototype.check = function (val) { 
     393jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 
    397394    var yy, mm, dd, th, tm, ts; 
    398395    if(this.lang.indexOf('fr_') == 0) { 
     
    439436    this.lang=''; 
    440437}; 
    441 jFormsControlLocaledate.prototype.check = function (val) { 
     438jFormsControlLocaledate.prototype.check = function (val, jfrm) { 
    442439    var yy, mm, dd; 
    443440    if(this.lang.indexOf('fr_') == 0) { 
     
    473470    this.help=''; 
    474471}; 
    475 jFormsControlUrl.prototype.check = function (val) { 
     472jFormsControlUrl.prototype.check = function (val, jfrm) { 
    476473    return (val.search(/^[a-z]+:\/\/((((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))((\/)|$)/) != -1); 
    477474}; 
     
    488485    this.help=''; 
    489486}; 
    490 jFormsControlEmail.prototype.check = function (val) { 
     487jFormsControlEmail.prototype.check = function (val, jfrm) { 
    491488    return (val.search(/^((\"[^\"f\n\r\t\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/) != -1); 
    492489}; 
     
    504501    this.help=''; 
    505502}; 
    506 jFormsControlIpv4.prototype.check = function (val) { 
     503jFormsControlIpv4.prototype.check = function (val, jfrm) { 
    507504    var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 
    508505    if(t) 
     
    522519    this.help=''; 
    523520}; 
    524 jFormsControlIpv6.prototype.check = function (val) { 
     521jFormsControlIpv6.prototype.check = function (val, jfrm) { 
    525522    return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 
    526523}; 
     
    550547    for(var i=0; i < list.length; i++) { 
    551548        var val2 = jfrm.getValue(jfrm.frmElt.elements[list[i].name]); 
    552         if (!list[i].check(val2, jfrm)) { 
     549 
     550        if (val2 == '') { 
     551            if (list[i].required) { 
     552                jfrm.tForm.errorDecorator.addError(list[i], 1); 
     553            } 
     554        } else if (!list[i].check(val2, jfrm)) { 
    553555            jfrm.tForm.errorDecorator.addError(list[i], 2); 
    554556        } 
  • branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js

    r985 r994  
    8585    }, 
    8686 
    87  
    8887    getValue : function (elt){ 
    8988        var value=''; 
    9089        if(elt.nodeType) { // this is a node 
    9190            switch (elt.nodeName.toLowerCase()) { 
    92                 case "input": 
    93                     switch (elt.getAttribute("type")) { 
    94                     case "checkbox": 
    95                     case "radio": 
    96                         if (elt.checked) 
    97                             value = 'true'; 
    98                         else 
    99                             value = 'false'; 
    100                         break; 
    101                     default: 
    102                         value = elt.value; 
    103                         break; 
     91            case "input": 
     92                switch (elt.getAttribute("type")) { 
     93                case "checkbox": 
     94                case "radio": 
     95                    if (elt.checked) 
     96                        value = 'true'; 
     97                    else 
     98                        value = 'false'; 
     99                    break; 
     100                default: 
     101                    value = elt.value; 
     102                    break; 
     103                } 
     104                break; 
     105            case "textarea": 
     106                value= elt.value; 
     107                break; 
     108            case "select": 
     109                if (!elt.multiple) { 
     110                    value =  elt.value; 
     111                    break; 
     112                } 
     113                var options = elt.getElementsByTagName("option"); 
     114                value = []; 
     115                for (var i = 0; i < options.length; i++) { 
     116                    if (options[i].selected) { 
     117                        value.push(options[i].value); 
    104118                    } 
    105                     break; 
    106                 case "textarea": 
    107                     value= elt.value; 
    108                     break; 
    109                 case "select": 
    110                     if (!elt.multiple) { 
    111                         value =  elt.value; 
    112                         break; 
    113                     } 
    114                     var options = elt.getElementsByTagName("option"); 
    115                     value = []; 
    116                     for (var i = 0; i < options.length; i++) { 
    117                         if (options[i].selected) { 
    118                             value.push(options[i].value); 
    119                         } 
    120                     } 
    121                     break; 
     119                } 
     120                break; 
    122121            } 
    123122        } else if(elt.item){ 
     
    194193    this.maxLength = -1; 
    195194}; 
    196 jFormsControlString.prototype.check = function (val) { 
     195jFormsControlString.prototype.check = function (val, jfrm) { 
    197196    if(this.minLength != -1 && val.length < this.minLength) 
    198197        return false; 
     
    241240}; 
    242241 
    243  
    244  
    245242/** 
    246243 * control with boolean 
     
    254251    this.help=''; 
    255252}; 
    256 jFormsControlBoolean.prototype.check = function (val) { 
     253jFormsControlBoolean.prototype.check = function (val, jfrm) { 
    257254    return (val == 'true' || val == 'false'); 
    258255}; 
     
    269266    this.help=''; 
    270267}; 
    271 jFormsControlDecimal.prototype.check = function (val) { 
     268jFormsControlDecimal.prototype.check = function (val, jfrm) { 
    272269    return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 
    273270}; 
     
    284281    this.help=''; 
    285282}; 
    286 jFormsControlInteger.prototype.check = function (val) { 
     283jFormsControlInteger.prototype.check = function (val, jfrm) { 
    287284    return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 
    288285}; 
     
    299296    this.help=''; 
    300297}; 
    301 jFormsControlHexadecimal.prototype.check = function (val) { 
     298jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 
    302299  return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 
    303300}; 
     
    314311    this.help=''; 
    315312}; 
    316 jFormsControlDatetime.prototype.check = function (val) { 
     313jFormsControlDatetime.prototype.check = function (val, jfrm) { 
    317314    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 
    318315    if(t == null) return false; 
     
    343340    this.help=''; 
    344341}; 
    345 jFormsControlDate.prototype.check = function (val) { 
     342jFormsControlDate.prototype.check = function (val, jfrm) { 
    346343    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 
    347344    if(t == null) return false; 
     
    367364    this.help=''; 
    368365}; 
    369 jFormsControlTime.prototype.check = function (val) { 
     366jFormsControlTime.prototype.check = function (val, jfrm) { 
    370367    var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 
    371368    if(t == null) return false; 
     
    394391    this.lang=''; 
    395392}; 
    396 jFormsControlLocaledatetime.prototype.check = function (val) { 
     393jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 
    397394    var yy, mm, dd, th, tm, ts; 
    398395    if(this.lang.indexOf('fr_') == 0) { 
     
    439436    this.lang=''; 
    440437}; 
    441 jFormsControlLocaledate.prototype.check = function (val) { 
     438jFormsControlLocaledate.prototype.check = function (val, jfrm) { 
    442439    var yy, mm, dd; 
    443440    if(this.lang.indexOf('fr_') == 0) { 
     
    473470    this.help=''; 
    474471}; 
    475 jFormsControlUrl.prototype.check = function (val) { 
     472jFormsControlUrl.prototype.check = function (val, jfrm) { 
    476473    return (val.search(/^[a-z]+:\/\/((((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))((\/)|$)/) != -1); 
    477474}; 
     
    488485    this.help=''; 
    489486}; 
    490 jFormsControlEmail.prototype.check = function (val) { 
     487jFormsControlEmail.prototype.check = function (val, jfrm) { 
    491488    return (val.search(/^((\"[^\"f\n\r\t\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/) != -1); 
    492489}; 
     
    504501    this.help=''; 
    505502}; 
    506 jFormsControlIpv4.prototype.check = function (val) { 
     503jFormsControlIpv4.prototype.check = function (val, jfrm) { 
    507504    var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 
    508505    if(t) 
     
    522519    this.help=''; 
    523520}; 
    524 jFormsControlIpv6.prototype.check = function (val) { 
     521jFormsControlIpv6.prototype.check = function (val, jfrm) { 
    525522    return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 
    526523}; 
     
    550547    for(var i=0; i < list.length; i++) { 
    551548        var val2 = jfrm.getValue(jfrm.frmElt.elements[list[i].name]); 
    552         if (!list[i].check(val2, jfrm)) { 
     549 
     550        if (val2 == '') { 
     551            if (list[i].required) { 
     552                jfrm.tForm.errorDecorator.addError(list[i], 1); 
     553            } 
     554        } else if (!list[i].check(val2, jfrm)) { 
    553555            jfrm.tForm.errorDecorator.addError(list[i], 2); 
    554556        } 
  • branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js

    r985 r994  
    8585    }, 
    8686 
    87  
    8887    getValue : function (elt){ 
    8988        var value=''; 
    9089        if(elt.nodeType) { // this is a node 
    9190            switch (elt.nodeName.toLowerCase()) { 
    92                 case "input": 
    93                     switch (elt.getAttribute("type")) { 
    94                     case "checkbox": 
    95                     case "radio": 
    96                         if (elt.checked) 
    97                             value = 'true'; 
    98                         else 
    99                             value = 'false'; 
    100                         break; 
    101                     default: 
    102                         value = elt.value; 
    103                         break; 
     91            case "input": 
     92                switch (elt.getAttribute("type")) { 
     93                case "checkbox": 
     94                case "radio": 
     95                    if (elt.checked) 
     96                        value = 'true'; 
     97                    else 
     98                        value = 'false'; 
     99                    break; 
     100                default: 
     101                    value = elt.value; 
     102                    break; 
     103                } 
     104                break; 
     105            case "textarea": 
     106                value= elt.value; 
     107                break; 
     108            case "select": 
     109                if (!elt.multiple) { 
     110                    value =  elt.value; 
     111                    break; 
     112                } 
     113                var options = elt.getElementsByTagName("option"); 
     114                value = []; 
     115                for (var i = 0; i < options.length; i++) { 
     116                    if (options[i].selected) { 
     117                        value.push(options[i].value); 
    104118                    } 
    105                     break; 
    106                 case "textarea": 
    107                     value= elt.value; 
    108                     break; 
    109                 case "select": 
    110                     if (!elt.multiple) { 
    111                         value =  elt.value; 
    112                         break; 
    113                     } 
    114                     var options = elt.getElementsByTagName("option"); 
    115                     value = []; 
    116                     for (var i = 0; i < options.length; i++) { 
    117                         if (options[i].selected) { 
    118                             value.push(options[i].value); 
    119                         } 
    120                     } 
    121                     break; 
     119                } 
     120                break; 
    122121            } 
    123122        } else if(elt.item){ 
     
    194193    this.maxLength = -1; 
    195194}; 
    196 jFormsControlString.prototype.check = function (val) { 
     195jFormsControlString.prototype.check = function (val, jfrm) { 
    197196    if(this.minLength != -1 && val.length < this.minLength) 
    198197        return false; 
     
    241240}; 
    242241 
    243  
    244  
    245242/** 
    246243 * control with boolean 
     
    254251    this.help=''; 
    255252}; 
    256 jFormsControlBoolean.prototype.check = function (val) { 
     253jFormsControlBoolean.prototype.check = function (val, jfrm) { 
    257254    return (val == 'true' || val == 'false'); 
    258255}; 
     
    269266    this.help=''; 
    270267}; 
    271 jFormsControlDecimal.prototype.check = function (val) { 
     268jFormsControlDecimal.prototype.check = function (val, jfrm) { 
    272269    return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 
    273270}; 
     
    284281    this.help=''; 
    285282}; 
    286 jFormsControlInteger.prototype.check = function (val) { 
     283jFormsControlInteger.prototype.check = function (val, jfrm) { 
    287284    return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 
    288285}; 
     
    299296    this.help=''; 
    300297}; 
    301 jFormsControlHexadecimal.prototype.check = function (val) { 
     298jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 
    302299  return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 
    303300}; 
     
    314311    this.help=''; 
    315312}; 
    316 jFormsControlDatetime.prototype.check = function (val) { 
     313jFormsControlDatetime.prototype.check = function (val, jfrm) { 
    317314    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 
    318315    if(t == null) return false; 
     
    343340    this.help=''; 
    344341}; 
    345 jFormsControlDate.prototype.check = function (val) { 
     342jFormsControlDate.prototype.check = function (val, jfrm) { 
    346343    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 
    347344    if(t == null) return false; 
     
    367364    this.help=''; 
    368365}; 
    369 jFormsControlTime.prototype.check = function (val) { 
     366jFormsControlTime.prototype.check = function (val, jfrm) { 
    370367    var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 
    371368    if(t == null) return false; 
     
    394391    this.lang=''; 
    395392}; 
    396 jFormsControlLocaledatetime.prototype.check = function (val) { 
     393jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 
    397394    var yy, mm, dd, th, tm, ts; 
    398395    if(this.lang.indexOf('fr_') == 0) { 
     
    439436    this.lang=''; 
    440437}; 
    441 jFormsControlLocaledate.prototype.check = function (val) { 
     438jFormsControlLocaledate.prototype.check = function (val, jfrm) { 
    442439    var yy, mm, dd; 
    443440    if(this.lang.indexOf('fr_') == 0) { 
     
    473470    this.help=''; 
    474471}; 
    475 jFormsControlUrl.prototype.check = function (val) { 
     472jFormsControlUrl.prototype.check = function (val, jfrm) { 
    476473    return (val.search(/^[a-z]+:\/\/((((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))((\/)|$)/) != -1); 
    477474}; 
     
    488485    this.help=''; 
    489486}; 
    490 jFormsControlEmail.prototype.check = function (val) { 
     487jFormsControlEmail.prototype.check = function (val, jfrm) { 
    491488    return (val.search(/^((\"[^\"f\n\r\t\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/) != -1); 
    492489}; 
     
    504501    this.help=''; 
    505502}; 
    506 jFormsControlIpv4.prototype.check = function (val) { 
     503jFormsControlIpv4.prototype.check = function (val, jfrm) { 
    507504    var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 
    508505    if(t) 
     
    522519    this.help=''; 
    523520}; 
    524 jFormsControlIpv6.prototype.check = function (val) { 
     521jFormsControlIpv6.prototype.check = function (val, jfrm) { 
    525522    return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 
    526523}; 
     
    550547    for(var i=0; i < list.length; i++) { 
    551548        var val2 = jfrm.getValue(jfrm.frmElt.elements[list[i].name]); 
    552         if (!list[i].check(val2, jfrm)) { 
     549 
     550        if (val2 == '') { 
     551            if (list[i].required) { 
     552                jfrm.tForm.errorDecorator.addError(list[i], 1); 
     553            } 
     554        } else if (!list[i].check(val2, jfrm)) { 
    553555            jfrm.tForm.errorDecorator.addError(list[i], 2); 
    554556        } 
  • branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js

    r985 r994  
    8585    }, 
    8686 
    87  
    8887    getValue : function (elt){ 
    8988        var value=''; 
    9089        if(elt.nodeType) { // this is a node 
    9190            switch (elt.nodeName.toLowerCase()) { 
    92                 case "input": 
    93                     switch (elt.getAttribute("type")) { 
    94                     case "checkbox": 
    95                     case "radio": 
    96                         if (elt.checked) 
    97                             value = 'true'; 
    98                         else 
    99                             value = 'false'; 
    100                         break; 
    101                     default: 
    102                         value = elt.value; 
    103                         break; 
     91            case "input": 
     92                switch (elt.getAttribute("type")) { 
     93                case "checkbox": 
     94                case "radio": 
     95                    if (elt.checked) 
     96                        value = 'true'; 
     97                    else 
     98                        value = 'false'; 
     99                    break; 
     100                default: 
     101                    value = elt.value; 
     102                    break; 
     103                } 
     104                break; 
     105            case "textarea": 
     106                value= elt.value; 
     107                break; 
     108            case "select": 
     109                if (!elt.multiple) { 
     110                    value =  elt.value; 
     111                    break; 
     112                } 
     113                var options = elt.getElementsByTagName("option"); 
     114                value = []; 
     115                for (var i = 0; i < options.length; i++) { 
     116                    if (options[i].selected) { 
     117                        value.push(options[i].value); 
    104118                    } 
    105                     break; 
    106                 case "textarea": 
    107                     value= elt.value; 
    108                     break; 
    109                 case "select": 
    110                     if (!elt.multiple) { 
    111                         value =  elt.value; 
    112                         break; 
    113                     } 
    114                     var options = elt.getElementsByTagName("option"); 
    115                     value = []; 
    116                     for (var i = 0; i < options.length; i++) { 
    117                         if (options[i].selected) { 
    118                             value.push(options[i].value); 
    119                         } 
    120                     } 
    121                     break; 
     119                } 
     120                break; 
    122121            } 
    123122        } else if(elt.item){ 
     
    194193    this.maxLength = -1; 
    195194}; 
    196 jFormsControlString.prototype.check = function (val) { 
     195jFormsControlString.prototype.check = function (val, jfrm) { 
    197196    if(this.minLength != -1 && val.length < this.minLength) 
    198197        return false; 
     
    241240}; 
    242241 
    243  
    244  
    245242/** 
    246243 * control with boolean 
     
    254251    this.help=''; 
    255252}; 
    256 jFormsControlBoolean.prototype.check = function (val) { 
     253jFormsControlBoolean.prototype.check = function (val, jfrm) { 
    257254    return (val == 'true' || val == 'false'); 
    258255}; 
     
    269266    this.help=''; 
    270267}; 
    271 jFormsControlDecimal.prototype.check = function (val) { 
     268jFormsControlDecimal.prototype.check = function (val, jfrm) { 
    272269    return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 
    273270}; 
     
    284281    this.help=''; 
    285282}; 
    286 jFormsControlInteger.prototype.check = function (val) { 
     283jFormsControlInteger.prototype.check = function (val, jfrm) { 
    287284    return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 
    288285}; 
     
    299296    this.help=''; 
    300297}; 
    301 jFormsControlHexadecimal.prototype.check = function (val) { 
     298jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 
    302299  return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 
    303300}; 
     
    314311    this.help=''; 
    315312}; 
    316 jFormsControlDatetime.prototype.check = function (val) { 
     313jFormsControlDatetime.prototype.check = function (val, jfrm) { 
    317314    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 
    318315    if(t == null) return false; 
     
    343340    this.help=''; 
    344341}; 
    345 jFormsControlDate.prototype.check = function (val) { 
     342jFormsControlDate.prototype.check = function (val, jfrm) { 
    346343    var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 
    347344    if(t == null) return false; 
     
    367364    this.help=''; 
    368365}; 
    369 jFormsControlTime.prototype.check = function (val) { 
     366jFormsControlTime.prototype.check = function (val, jfrm) { 
    370367    var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 
    371368    if(t == null) return false; 
     
    394391    this.lang=''; 
    395392}; 
    396 jFormsControlLocaledatetime.prototype.check = function (val) { 
     393jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 
    397394    var yy, mm, dd, th, tm, ts; 
    398395    if(this.lang.indexOf('fr_') == 0) { 
     
    439436    this.lang=''; 
    440437}; 
    441 jFormsControlLocaledate.prototype.check = function (val) { 
     438jFormsControlLocaledate.prototype.check = function (val, jfrm) { 
    442439    var yy, mm, dd; 
    443440    if(this.lang.indexOf('fr_') == 0) { 
     
    473470    this.help=''; 
    474471}; 
    475 jFormsControlUrl.prototype.check = function (val) { 
     472jFormsControlUrl.prototype.check = function (val, jfrm) { 
    476473    return (val.search(/^[a-z]+:\/\/((((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))((\/)|$)/) != -1); 
    477474}; 
     
    488485    this.help=''; 
    489486}; 
    490 jFormsControlEmail.prototype.check = function (val) { 
     487jFormsControlEmail.prototype.check = function (val, jfrm) { 
    491488    return (val.search(/^((\"[^\"f\n\r\t\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/) != -1); 
    492489}; 
     
    504501    this.help=''; 
    505502}; 
    506 jFormsControlIpv4.prototype.check = function (val) { 
     503jFormsControlIpv4.prototype.check = function (val, jfrm) { 
    507504    var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 
    508505    if(t) 
     
    522519    this.help=''; 
    523520}; 
    524 jFormsControlIpv6.prototype.check = function (val) { 
     521jFormsControlIpv6.prototype.check = function (val, jfrm) { 
    525522    return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 
    526523}; 
     
    550547    for(var i=0; i < list.length; i++) { 
    551548        var val2 = jfrm.getValue(jfrm.frmElt.elements[list[i].name]); 
    552         if (!list[i].check(val2, jfrm)) { 
     549 
     550        if (val2 == '') { 
     551            if (list[i].required) { 
     552                jfrm.tForm.errorDecorator.addError(list[i], 1); 
     553            } 
     554        } else if (!list[i].check(val2, jfrm)) { 
    553555            jfrm.tForm.errorDecorator.addError(list[i], 2); 
    554556        } 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

    r985 r994  
    7676        } 
    7777 
    78         if(!isset($attributes['ref'])){ 
     78        if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 
    7979            throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 
    8080        } 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

    r985 r994  
    7676        } 
    7777 
    78         if(!isset($attributes['ref'])){ 
     78        if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 
    7979            throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 
    8080        } 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

    r985 r994  
    7676        } 
    7777 
    78         if(!isset($attributes['ref'])){ 
     78        if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 
    7979            throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 
    8080        } 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

    r985 r994  
    7676        } 
    7777 
    78         if(!isset($attributes['ref'])){ 
     78        if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 
    7979            throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 
    8080        } 
  • branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r967 r994  
    144144    public function outputControlLabel($ctrl){ 
    145145        if($ctrl->type == 'hidden' || $ctrl->type == 'group') return; 
    146         $required = ($ctrl->required == ''|| $ctrl->isReadOnly()?'':' jforms-required'); 
     146        $required = ($ctrl->required == false || $ctrl->isReadOnly()?'':' jforms-required'); 
    147147        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
    148148        $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
     
    159159        $ro = $ctrl->isReadOnly(); 
    160160        $id = ' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'"'; 
    161         $class = ($ctrl->required == ''|| $ro?'':' jforms-required'); 
     161        $class = ($ctrl->required == false || $ro?'':' jforms-required'); 
    162162        $class.= (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
    163163        if($class !='') $class = ' class="'.$class.'"'; 
     
    323323 
    324324    protected function outputOutput($ctrl, $id, $class, $readonly, $hint) { 
    325             $value = $this->_form->getData($ctrl->ref); 
    326             echo '<input type="hidden"',$id,' value="',htmlspecialchars($value),'"',$this->_endt; 
    327             echo '<span class="jforms-value"',$hint,'>',htmlspecialchars($value),'</span>'; 
     325        $value = $this->_form->getData($ctrl->ref); 
     326        echo '<input type="hidden"',$id,' value="',htmlspecialchars($value),'"',$this->_endt; 
     327        echo '<span class="jforms-value