You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Greg Woolsey (JIRA)" <ta...@jakarta.apache.org> on 2006/10/03 01:05:19 UTC

[jira] Commented: (TAPESTRY-1107) Required Field validation behavior changed between 4.0 and 4.1.1

    [ http://issues.apache.org/jira/browse/TAPESTRY-1107?page=comments#action_12439340 ] 
            
Greg Woolsey commented on TAPESTRY-1107:
----------------------------------------

One possible solution - here is a solution inside an updated If statement for required fields for context:

	// See if required input fields have values missing.
	if ( profile.required instanceof Array ) {
		for (var i = 0; i < profile.required.length; i++) { 
			if(!dojo.lang.isString(profile.required[i])){ continue; }
			var elem = form[profile.required[i]];
			// Are textbox, textarea, or password fields blank.
			if ( (elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value) ) {	
				missing[missing.length] = elem.name;
			}
			// Does drop-down box have option selected.
			else if ( (elem.type == "select-one" || elem.type == "select-multiple") ) {
				if (elem.selectedIndex == -1 ) {
					missing[missing.length] = elem.name;
				} else {
					var isMissing = true;
					for (var j = 0; j < elem.options.length; j++) {
						if (elem.options[j].selected && ! (/^\s*$/.test(elem.options[j].value)) ) { 
							isMissing = false;
							break;
						}
					}
					if (isMissing) missing[missing.length] = elem.name;
				}
			}
			// Does radio button group (or check box group) have option checked.
			else if ( elem instanceof Array )  {
				var checked = false;
				for (var j = 0; j < elem.length; j++) {
					if (elem[j].checked) { checked = true; }
				}
				if ( !checked ) {	
					missing[missing.length] = elem[0].name;
				}
			}
		}
	}



> Required Field validation behavior changed between 4.0 and 4.1.1
> ----------------------------------------------------------------
>
>                 Key: TAPESTRY-1107
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1107
>             Project: Tapestry
>          Issue Type: Bug
>          Components: JavaScript
>    Affects Versions: 4.1.1
>            Reporter: Greg Woolsey
>
> In 4.0, a Select list with a selection with an empty value failed the required field validation.  In 4.1.1, if any item is selected it is valid, even if that item has no value.
> The old behavior worked with Java validation, the new one does not - a selection with a null/empty value submits null, which fails server-side validation.
> The problem is in dojo.validate.check() line 100 in the current snapshot.
> Since this is in Dojo, that behavior may be the desired default, but Tapestry needs a modified behavior with an additional condition - if the element is a select-one or select-multiple, if it has a selection that selection (or at least one of the selections) must not have an empty value.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org