Changeset 994
- Timestamp:
- 06/18/08 00:33:58 (6 months ago)
- Files:
-
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (17 diffs)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (17 diffs)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (17 diffs)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (17 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (2 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r985 r994 85 85 }, 86 86 87 88 87 getValue : function (elt){ 89 88 var value=''; 90 89 if(elt.nodeType) { // this is a node 91 90 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); 104 118 } 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; 122 121 } 123 122 } else if(elt.item){ … … 194 193 this.maxLength = -1; 195 194 }; 196 jFormsControlString.prototype.check = function (val ) {195 jFormsControlString.prototype.check = function (val, jfrm) { 197 196 if(this.minLength != -1 && val.length < this.minLength) 198 197 return false; … … 241 240 }; 242 241 243 244 245 242 /** 246 243 * control with boolean … … 254 251 this.help=''; 255 252 }; 256 jFormsControlBoolean.prototype.check = function (val ) {253 jFormsControlBoolean.prototype.check = function (val, jfrm) { 257 254 return (val == 'true' || val == 'false'); 258 255 }; … … 269 266 this.help=''; 270 267 }; 271 jFormsControlDecimal.prototype.check = function (val ) {268 jFormsControlDecimal.prototype.check = function (val, jfrm) { 272 269 return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 273 270 }; … … 284 281 this.help=''; 285 282 }; 286 jFormsControlInteger.prototype.check = function (val ) {283 jFormsControlInteger.prototype.check = function (val, jfrm) { 287 284 return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 288 285 }; … … 299 296 this.help=''; 300 297 }; 301 jFormsControlHexadecimal.prototype.check = function (val ) {298 jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 302 299 return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 303 300 }; … … 314 311 this.help=''; 315 312 }; 316 jFormsControlDatetime.prototype.check = function (val ) {313 jFormsControlDatetime.prototype.check = function (val, jfrm) { 317 314 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 318 315 if(t == null) return false; … … 343 340 this.help=''; 344 341 }; 345 jFormsControlDate.prototype.check = function (val ) {342 jFormsControlDate.prototype.check = function (val, jfrm) { 346 343 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 347 344 if(t == null) return false; … … 367 364 this.help=''; 368 365 }; 369 jFormsControlTime.prototype.check = function (val ) {366 jFormsControlTime.prototype.check = function (val, jfrm) { 370 367 var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 371 368 if(t == null) return false; … … 394 391 this.lang=''; 395 392 }; 396 jFormsControlLocaledatetime.prototype.check = function (val ) {393 jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 397 394 var yy, mm, dd, th, tm, ts; 398 395 if(this.lang.indexOf('fr_') == 0) { … … 439 436 this.lang=''; 440 437 }; 441 jFormsControlLocaledate.prototype.check = function (val ) {438 jFormsControlLocaledate.prototype.check = function (val, jfrm) { 442 439 var yy, mm, dd; 443 440 if(this.lang.indexOf('fr_') == 0) { … … 473 470 this.help=''; 474 471 }; 475 jFormsControlUrl.prototype.check = function (val ) {472 jFormsControlUrl.prototype.check = function (val, jfrm) { 476 473 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); 477 474 }; … … 488 485 this.help=''; 489 486 }; 490 jFormsControlEmail.prototype.check = function (val ) {487 jFormsControlEmail.prototype.check = function (val, jfrm) { 491 488 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); 492 489 }; … … 504 501 this.help=''; 505 502 }; 506 jFormsControlIpv4.prototype.check = function (val ) {503 jFormsControlIpv4.prototype.check = function (val, jfrm) { 507 504 var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 508 505 if(t) … … 522 519 this.help=''; 523 520 }; 524 jFormsControlIpv6.prototype.check = function (val ) {521 jFormsControlIpv6.prototype.check = function (val, jfrm) { 525 522 return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 526 523 }; … … 550 547 for(var i=0; i < list.length; i++) { 551 548 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)) { 553 555 jfrm.tForm.errorDecorator.addError(list[i], 2); 554 556 } branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r985 r994 85 85 }, 86 86 87 88 87 getValue : function (elt){ 89 88 var value=''; 90 89 if(elt.nodeType) { // this is a node 91 90 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); 104 118 } 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; 122 121 } 123 122 } else if(elt.item){ … … 194 193 this.maxLength = -1; 195 194 }; 196 jFormsControlString.prototype.check = function (val ) {195 jFormsControlString.prototype.check = function (val, jfrm) { 197 196 if(this.minLength != -1 && val.length < this.minLength) 198 197 return false; … … 241 240 }; 242 241 243 244 245 242 /** 246 243 * control with boolean … … 254 251 this.help=''; 255 252 }; 256 jFormsControlBoolean.prototype.check = function (val ) {253 jFormsControlBoolean.prototype.check = function (val, jfrm) { 257 254 return (val == 'true' || val == 'false'); 258 255 }; … … 269 266 this.help=''; 270 267 }; 271 jFormsControlDecimal.prototype.check = function (val ) {268 jFormsControlDecimal.prototype.check = function (val, jfrm) { 272 269 return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 273 270 }; … … 284 281 this.help=''; 285 282 }; 286 jFormsControlInteger.prototype.check = function (val ) {283 jFormsControlInteger.prototype.check = function (val, jfrm) { 287 284 return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 288 285 }; … … 299 296 this.help=''; 300 297 }; 301 jFormsControlHexadecimal.prototype.check = function (val ) {298 jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 302 299 return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 303 300 }; … … 314 311 this.help=''; 315 312 }; 316 jFormsControlDatetime.prototype.check = function (val ) {313 jFormsControlDatetime.prototype.check = function (val, jfrm) { 317 314 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 318 315 if(t == null) return false; … … 343 340 this.help=''; 344 341 }; 345 jFormsControlDate.prototype.check = function (val ) {342 jFormsControlDate.prototype.check = function (val, jfrm) { 346 343 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 347 344 if(t == null) return false; … … 367 364 this.help=''; 368 365 }; 369 jFormsControlTime.prototype.check = function (val ) {366 jFormsControlTime.prototype.check = function (val, jfrm) { 370 367 var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 371 368 if(t == null) return false; … … 394 391 this.lang=''; 395 392 }; 396 jFormsControlLocaledatetime.prototype.check = function (val ) {393 jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 397 394 var yy, mm, dd, th, tm, ts; 398 395 if(this.lang.indexOf('fr_') == 0) { … … 439 436 this.lang=''; 440 437 }; 441 jFormsControlLocaledate.prototype.check = function (val ) {438 jFormsControlLocaledate.prototype.check = function (val, jfrm) { 442 439 var yy, mm, dd; 443 440 if(this.lang.indexOf('fr_') == 0) { … … 473 470 this.help=''; 474 471 }; 475 jFormsControlUrl.prototype.check = function (val ) {472 jFormsControlUrl.prototype.check = function (val, jfrm) { 476 473 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); 477 474 }; … … 488 485 this.help=''; 489 486 }; 490 jFormsControlEmail.prototype.check = function (val ) {487 jFormsControlEmail.prototype.check = function (val, jfrm) { 491 488 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); 492 489 }; … … 504 501 this.help=''; 505 502 }; 506 jFormsControlIpv4.prototype.check = function (val ) {503 jFormsControlIpv4.prototype.check = function (val, jfrm) { 507 504 var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 508 505 if(t) … … 522 519 this.help=''; 523 520 }; 524 jFormsControlIpv6.prototype.check = function (val ) {521 jFormsControlIpv6.prototype.check = function (val, jfrm) { 525 522 return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 526 523 }; … … 550 547 for(var i=0; i < list.length; i++) { 551 548 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)) { 553 555 jfrm.tForm.errorDecorator.addError(list[i], 2); 554 556 } branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r985 r994 85 85 }, 86 86 87 88 87 getValue : function (elt){ 89 88 var value=''; 90 89 if(elt.nodeType) { // this is a node 91 90 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); 104 118 } 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; 122 121 } 123 122 } else if(elt.item){ … … 194 193 this.maxLength = -1; 195 194 }; 196 jFormsControlString.prototype.check = function (val ) {195 jFormsControlString.prototype.check = function (val, jfrm) { 197 196 if(this.minLength != -1 && val.length < this.minLength) 198 197 return false; … … 241 240 }; 242 241 243 244 245 242 /** 246 243 * control with boolean … … 254 251 this.help=''; 255 252 }; 256 jFormsControlBoolean.prototype.check = function (val ) {253 jFormsControlBoolean.prototype.check = function (val, jfrm) { 257 254 return (val == 'true' || val == 'false'); 258 255 }; … … 269 266 this.help=''; 270 267 }; 271 jFormsControlDecimal.prototype.check = function (val ) {268 jFormsControlDecimal.prototype.check = function (val, jfrm) { 272 269 return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 273 270 }; … … 284 281 this.help=''; 285 282 }; 286 jFormsControlInteger.prototype.check = function (val ) {283 jFormsControlInteger.prototype.check = function (val, jfrm) { 287 284 return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 288 285 }; … … 299 296 this.help=''; 300 297 }; 301 jFormsControlHexadecimal.prototype.check = function (val ) {298 jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 302 299 return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 303 300 }; … … 314 311 this.help=''; 315 312 }; 316 jFormsControlDatetime.prototype.check = function (val ) {313 jFormsControlDatetime.prototype.check = function (val, jfrm) { 317 314 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 318 315 if(t == null) return false; … … 343 340 this.help=''; 344 341 }; 345 jFormsControlDate.prototype.check = function (val ) {342 jFormsControlDate.prototype.check = function (val, jfrm) { 346 343 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 347 344 if(t == null) return false; … … 367 364 this.help=''; 368 365 }; 369 jFormsControlTime.prototype.check = function (val ) {366 jFormsControlTime.prototype.check = function (val, jfrm) { 370 367 var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 371 368 if(t == null) return false; … … 394 391 this.lang=''; 395 392 }; 396 jFormsControlLocaledatetime.prototype.check = function (val ) {393 jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 397 394 var yy, mm, dd, th, tm, ts; 398 395 if(this.lang.indexOf('fr_') == 0) { … … 439 436 this.lang=''; 440 437 }; 441 jFormsControlLocaledate.prototype.check = function (val ) {438 jFormsControlLocaledate.prototype.check = function (val, jfrm) { 442 439 var yy, mm, dd; 443 440 if(this.lang.indexOf('fr_') == 0) { … … 473 470 this.help=''; 474 471 }; 475 jFormsControlUrl.prototype.check = function (val ) {472 jFormsControlUrl.prototype.check = function (val, jfrm) { 476 473 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); 477 474 }; … … 488 485 this.help=''; 489 486 }; 490 jFormsControlEmail.prototype.check = function (val ) {487 jFormsControlEmail.prototype.check = function (val, jfrm) { 491 488 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); 492 489 }; … … 504 501 this.help=''; 505 502 }; 506 jFormsControlIpv4.prototype.check = function (val ) {503 jFormsControlIpv4.prototype.check = function (val, jfrm) { 507 504 var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 508 505 if(t) … … 522 519 this.help=''; 523 520 }; 524 jFormsControlIpv6.prototype.check = function (val ) {521 jFormsControlIpv6.prototype.check = function (val, jfrm) { 525 522 return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 526 523 }; … … 550 547 for(var i=0; i < list.length; i++) { 551 548 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)) { 553 555 jfrm.tForm.errorDecorator.addError(list[i], 2); 554 556 } branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r985 r994 85 85 }, 86 86 87 88 87 getValue : function (elt){ 89 88 var value=''; 90 89 if(elt.nodeType) { // this is a node 91 90 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); 104 118 } 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; 122 121 } 123 122 } else if(elt.item){ … … 194 193 this.maxLength = -1; 195 194 }; 196 jFormsControlString.prototype.check = function (val ) {195 jFormsControlString.prototype.check = function (val, jfrm) { 197 196 if(this.minLength != -1 && val.length < this.minLength) 198 197 return false; … … 241 240 }; 242 241 243 244 245 242 /** 246 243 * control with boolean … … 254 251 this.help=''; 255 252 }; 256 jFormsControlBoolean.prototype.check = function (val ) {253 jFormsControlBoolean.prototype.check = function (val, jfrm) { 257 254 return (val == 'true' || val == 'false'); 258 255 }; … … 269 266 this.help=''; 270 267 }; 271 jFormsControlDecimal.prototype.check = function (val ) {268 jFormsControlDecimal.prototype.check = function (val, jfrm) { 272 269 return ( -1 != val.search(/^\s*[\+\-]?\d+(\.\d+)?\s*$/)); 273 270 }; … … 284 281 this.help=''; 285 282 }; 286 jFormsControlInteger.prototype.check = function (val ) {283 jFormsControlInteger.prototype.check = function (val, jfrm) { 287 284 return ( -1 != val.search(/^\s*[\+\-]?\d+\s*$/)); 288 285 }; … … 299 296 this.help=''; 300 297 }; 301 jFormsControlHexadecimal.prototype.check = function (val ) {298 jFormsControlHexadecimal.prototype.check = function (val, jfrm) { 302 299 return (val.search(/^0x[a-f0-9A-F]+$/) != -1); 303 300 }; … … 314 311 this.help=''; 315 312 }; 316 jFormsControlDatetime.prototype.check = function (val ) {313 jFormsControlDatetime.prototype.check = function (val, jfrm) { 317 314 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/); 318 315 if(t == null) return false; … … 343 340 this.help=''; 344 341 }; 345 jFormsControlDate.prototype.check = function (val ) {342 jFormsControlDate.prototype.check = function (val, jfrm) { 346 343 var t = val.match(/^(\d{4})\-(\d{2})\-(\d{2})$/); 347 344 if(t == null) return false; … … 367 364 this.help=''; 368 365 }; 369 jFormsControlTime.prototype.check = function (val ) {366 jFormsControlTime.prototype.check = function (val, jfrm) { 370 367 var t = val.match(/^(\d{2}):(\d{2})(:(\d{2}))?$/); 371 368 if(t == null) return false; … … 394 391 this.lang=''; 395 392 }; 396 jFormsControlLocaledatetime.prototype.check = function (val ) {393 jFormsControlLocaledatetime.prototype.check = function (val, jfrm) { 397 394 var yy, mm, dd, th, tm, ts; 398 395 if(this.lang.indexOf('fr_') == 0) { … … 439 436 this.lang=''; 440 437 }; 441 jFormsControlLocaledate.prototype.check = function (val ) {438 jFormsControlLocaledate.prototype.check = function (val, jfrm) { 442 439 var yy, mm, dd; 443 440 if(this.lang.indexOf('fr_') == 0) { … … 473 470 this.help=''; 474 471 }; 475 jFormsControlUrl.prototype.check = function (val ) {472 jFormsControlUrl.prototype.check = function (val, jfrm) { 476 473 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); 477 474 }; … … 488 485 this.help=''; 489 486 }; 490 jFormsControlEmail.prototype.check = function (val ) {487 jFormsControlEmail.prototype.check = function (val, jfrm) { 491 488 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); 492 489 }; … … 504 501 this.help=''; 505 502 }; 506 jFormsControlIpv4.prototype.check = function (val ) {503 jFormsControlIpv4.prototype.check = function (val, jfrm) { 507 504 var t = val.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); 508 505 if(t) … … 522 519 this.help=''; 523 520 }; 524 jFormsControlIpv6.prototype.check = function (val ) {521 jFormsControlIpv6.prototype.check = function (val, jfrm) { 525 522 return (val.search(/^([a-f0-9]{1,4})(:([a-f0-9]{1,4})){7}$/i) != -1); 526 523 }; … … 550 547 for(var i=0; i < list.length; i++) { 551 548 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)) { 553 555 jfrm.tForm.errorDecorator.addError(list[i], 2); 554 556 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r985 r994 76 76 } 77 77 78 if(!isset($attributes['ref']) ){78 if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 79 79 throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 80 80 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r985 r994 76 76 } 77 77 78 if(!isset($attributes['ref']) ){78 if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 79 79 throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 80 80 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r985 r994 76 76 } 77 77 78 if(!isset($attributes['ref']) ){78 if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 79 79 throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 80 80 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r985 r994 76 76 } 77 77 78 if(!isset($attributes['ref']) ){78 if(!isset($attributes['ref']) || $attributes['ref'] == ''){ 79 79 throw new jException('jelix~formserr.attribute.missing',array('ref',$controltype,$this->sourceFile)); 80 80 } branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r967 r994 144 144 public function outputControlLabel($ctrl){ 145 145 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'); 147 147 $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 148 148 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); … … 159 159 $ro = $ctrl->isReadOnly(); 160 160 $id = ' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'"'; 161 $class = ($ctrl->required == ''|| $ro?'':' jforms-required');161 $class = ($ctrl->required == false || $ro?'':' jforms-required'); 162 162 $class.= (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 163 163 if($class !='') $class = ' class="'.$class.'"'; … … 323 323 324 324 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
