Re: Complex Form Validation
George, I have done something similar to this. I haven't looked at browser compatability yet(we're currently using this with ie6), but the concept that I use is that I look at the parents of the form field, trying to find out if the element is hidden. If I find that a parent that is hidden, then I take appropriate action. My javascript loop looks like this: var hiddenParent = false; for(parent=formField.parentElement; parent != null hiddenParent == false; parent = parent.parentElement) { if(parent.currentStyle.display == none) { hiddenParent = true; } } if(hiddenParent) { etc, etc } Hope this helps a little. If there are better ways to do this, I'd love to get the feedback :-) Nick George Steimer [EMAIL PROTECTED]To: [EMAIL PROTECTED] m cc: Subject: Complex Form Validation 11/18/2003 02:18 PM Please respond to Struts Users Mailing List We are trying to perform some complex form validaion with the new Validator plugin. Here is what we are trying to do: 1 -- validate a form field based on other form fields 2 -- validate a form field based on div style settings I know that I could solve the first problem with the old validation architecture, but is there a way to do that through the validator.xml? I'm not sure about the second problem. The code looks something like this div id=myDiv style=display: none //my form element here /div So is it possible to only validate the form element above only if the enclosing div display is block? I've looked, but couldn't find anything explaining how to go about this. Any ideas? Thanks in advance, George - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Complex Form Validation
Nick, Thanks for your response. I'm doing something similar with javascript. What would be better is if we could validate the form serverside with the validation framework... I think we would have to write a custom validator that somehow would get the div parent of the form field and check that before checking the actual field. Thanks, George George, I have done something similar to this. I haven't looked at browser compatability yet(we're currently using this with ie6), but the concept that I use is that I look at the parents of the form field, trying to find out if the element is hidden. If I find that a parent that is hidden, then I take appropriate action. My javascript loop looks like this: var hiddenParent = false; for(parent=formField.parentElement; parent != null hiddenParent == false; parent = parent.parentElement) { if(parent.currentStyle.display == none) { hiddenParent = true; } } if(hiddenParent) { etc, etc } Hope this helps a little. If there are better ways to do this, I'd love to get the feedback :-) Nick George Steimer [EMAIL PROTECTED]To: [EMAIL PROTECTED] m cc: Subject: Complex Form Validation 11/18/2003 02:18 PM Please respond to Struts Users Mailing List We are trying to perform some complex form validaion with the new Validator plugin. Here is what we are trying to do: 1 -- validate a form field based on other form fields 2 -- validate a form field based on div style settings I know that I could solve the first problem with the old validation architecture, but is there a way to do that through the validator.xml? I'm not sure about the second problem. The code looks something like this div id=myDiv style=display: none //my form element here /div So is it possible to only validate the form element above only if the enclosing div display is block? I've looked, but couldn't find anything explaining how to go about this. Any ideas? Thanks in advance, George - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Complex Form Validation
George, You can't do the validation server-side as you proposed because the browser only sends HTML form elements. It will not send any information regarding the div tag. You would have to have a hidden form variable and use JavaScript to populate it with any values of interest when the form is submitted. Regards, Richard -Original Message- From: George Steimer [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 11:51 AM To: Struts Users Mailing List Subject: Re: Complex Form Validation Nick, Thanks for your response. I'm doing something similar with javascript. What would be better is if we could validate the form serverside with the validation framework... I think we would have to write a custom validator that somehow would get the div parent of the form field and check that before checking the actual field. Thanks, George George, I have done something similar to this. I haven't looked at browser compatability yet(we're currently using this with ie6), but the concept that I use is that I look at the parents of the form field, trying to find out if the element is hidden. If I find that a parent that is hidden, then I take appropriate action. My javascript loop looks like this: var hiddenParent = false; for(parent=formField.parentElement; parent != null hiddenParent == false; parent = parent.parentElement) { if(parent.currentStyle.display == none) { hiddenParent = true; } } if(hiddenParent) { etc, etc } Hope this helps a little. If there are better ways to do this, I'd love to get the feedback :-) Nick George Steimer [EMAIL PROTECTED]To: [EMAIL PROTECTED] m cc: Subject: Complex Form Validation 11/18/2003 02:18 PM Please respond to Struts Users Mailing List We are trying to perform some complex form validaion with the new Validator plugin. Here is what we are trying to do: 1 -- validate a form field based on other form fields 2 -- validate a form field based on div style settings I know that I could solve the first problem with the old validation architecture, but is there a way to do that through the validator.xml? I'm not sure about the second problem. The code looks something like this div id=myDiv style=display: none //my form element here /div So is it possible to only validate the form element above only if the enclosing div display is block? I've looked, but couldn't find anything explaining how to go about this. Any ideas? Thanks in advance, George - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]