0

I am working on a Spring WebFlow project that is using Dojo (dijit) for the forms and if the user does now fill in a textfield that is required the field does turn red on the click of the submit button. But radio buttons and checkboxes dont..

1) How can I make a radio button and checkbox act like text fields and turn red?

2) How can I change the following code popup a messages that the user has to fix some text fields.

<input type="submit" name="_eventId_submit" id="submit" value="Submit"  tabindex="11" />
<script type="text/javascript">
            Spring.addDecoration(new Spring.ValidateAllDecoration({
                elementId : 'submit',
                event : 'onclick'
            }));
        </script>
techsjs2012
  • 1,737
  • 5
  • 25
  • 57
  • for 1) I guess you could use the `validate` function of your radiobutton and checkbox to change the color via javascript. – rptmat57 Oct 16 '12 at 15:47
  • thanks rptmat57 but you know I am not going to understand how to do it yet. looking for examples. – techsjs2012 Oct 16 '12 at 16:53
  • actually, 1) might not be possible http://stackoverflow.com/questions/4253920/how-do-i-change-the-color-of-radio-buttons – rptmat57 Oct 16 '12 at 17:35
  • thanks.. how about the other question.. #2 Making a popup if any fields dont pass the checks – techsjs2012 Oct 16 '12 at 18:40

1 Answers1

1

for 2) you can use Spring.validateAll() instead of the ValidateAllDecoration. (you have to remove the ValidateAllDecoration)

the function Spring.validateAll() return true or false depending on the validation results.

something like that on the onClick:

onclick="if(!Spring.validateAll()){alert('errors')}else{Spring.submitForm(...)}"

should work

rptmat57
  • 3,643
  • 1
  • 27
  • 38