Forums

Customising Validation behaviour

GreyHead 04 Mar, 2011
Hi,

With a little hack of the code you can customise the validation. Open the file administrator/com_chronoforms/form_actions/show_html/cfaction_show_html.php and find the script snippet that sets up the formCheck around line 149:
		//<![CDATA[
			window.addEvent('domready', function() {
				formCheck = new FormCheck('<?php echo 'chronoform_'.$form->form_name; ?>', {
			});										
			});
		//]]>

You can add options into the empty space here to configure the way FormCheck works. See the FormCheck docs for the list of options.

Here's one (experimental) example:
		//<![CDATA[
			window.addEvent('domready', function() {
				formCheck = new FormCheck('<?php echo 'chronoform_'.$form->form_name; ?>', {
					display : {
                    	showErrors : 1,
                    	addClassErrorToField : 1
                        },
                    alerts : {required : 'Yah boo sucks to you' }
	});										
			});
		//]]>
This tells FormCheck[list]
  • to show error messages on Submit *and* on blur
  • to add an error class to the input 'fc-field-error'
  • to use a custom message for the required validation.
  • [/list]
    With the error class enabled you can add CSS to the Form using a Load CSS event to apply to error inputs:
    .fc-field-error {
      background-color:teal;
      border: 3px solid yellow !important;
    }

    Bob

    PS I don't recommend this CSS, or this message!
    This topic is locked and no more replies can be posted.