Submit button active conditional..

Ron 16 Apr, 2012
Hello,

I have some forms on my website that require all the fields to be filled in. I want to make the submit button active only when all required fields are filled in till then the submit button should remain greyed out.

I tried but could not succeed. Would the forum help please ?

Thanks

Ron
GreyHead 16 Apr, 2012
Hi Ron,

Is this ChronoForms v4? Are are all the inputs text inputs or are there other types as well?

Bob
Ron 17 Apr, 2012
Yes Bob,

I am using the CF V.4 and type="text"

Thanks

Ron
GreyHead 21 Apr, 2012
Hi Ron,

If you have a class='required' to identify the required inputs then something like this should work:
window.addEvent('domready', function() {
  $('submit').disabled = true;
  var req = $$('form#form_id input.required');
  req.each(function(item){
    item.addEvent('keyup', allowSubmit);
  });
  function allowSubmit() {
    var submit = req.every(function(item) {
      item.value != '';
    });
    if ( submit ) {
      $('submit').disabled = false;
    } else {
      $('submit').disabled = true;
    }
  }
});
ot tested and will need debugging!

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