Remove error validation on field when click on another field

cosmicfantasia 08 Mar, 2011
Hi,

Me again. Need to be able to remove the error validation so that only 1 error exists @ a time. Please see http://massmosaic.com/joomla/

The client doesn't want to have the potential for a whole bunch of red being on the screen @ once. We are also now using position:absolute to have any of the errors display in 1 place only. So if there is both an email address error and a field not being entered the text goes over the top of each other. As is currently on this site.
GreyHead 08 Mar, 2011
Hi cosmicfantasia,

You can do this with JavaScript. Here's a snippet that works onSubmit
window.addEvent('domready', function() {
  $('ChronoContact_my_form_name').addEvent('submit', function() {
    var messages = $$('span.LV_invalid');
    if ( messages.length > 1 ) {
      messages.each(function(item, index) {
        if ( index > 0 ) {
          item.setStyle('display', 'none');
        } else {
          item.setStyle('display', 'block');
        }
      });
    }
  });
});
Note: replace 'my_form_name' with the name of your form.

Bob
cosmicfantasia 08 Mar, 2011
Thanks but we need it to happen live b4 the submit.

To better replicate the problem.

1) Goto above url

2) click in the email field

3) click in the next field and repeat..

You'll see they all stay red and it still doesn't remove the previous errors which is what we actually require
GreyHead 08 Mar, 2011
Hi cosmicfantasia,

Sure, then you'll need to work on the script so that it fits with the way you have the form set up.

Bob
cosmicfantasia 08 Mar, 2011
Any pointers? Apart from the css to make the error messages appear in the same place. Its a pretty stock standard joomla reg form.
GreyHead 08 Mar, 2011
Hi cosmicfantasia,

I'm not sure why you are expecting me to fix the changes that you and your client have made?

I'd probably try testing onClick events as triggers for the code. Or switch the validation so that it only runs on submit.

Bob
This topic is locked and no more replies can be posted.