By default submit button should be disabled

By default submit button should be disabled

by Web Developer -
Number of replies: 2

Hi,

I want to create a submit button by default disabled and also control with a checkbox. if I click on the checkbox then the button should be enabled otherwise show disabled. 

here is my code:

$mform->addElement('advcheckbox', 'checkbox1', 'I have read all the above instruction and is ready to submit.', null, array(

'onClick'=>"enable();"));

$buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('submit'),array('onClick'=>"return confirm('Are you sure you want to submit ');"));

Can anyone help me please?




Average of ratings: -
In reply to Web Developer

Re: By default submit button should be disabled

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Have a look at disabledIf, it lets you disable a form element based on the value of other elements.

Average of ratings: Useful (1)