// Initialize the form, add it to the session if it does not exist
// Create the form
$validations = new JFormer('validationForm', array(
'action' => str_replace($_SERVER['DOCUMENT_ROOT'], '', __FILE__),
));
// Create the form page
$jFormPage1 = new JFormPage($validations->id.'Page', array(
'title' => 'Validations Demo
',
'description' => 'This is a demonstration of some of jFormer\'s validations.
For a full list of available validations please visit out documentation
'
));
// Create the form section
$jFormSection1 = new JFormSection($validations->id.'Section', array(
'title' => 'Text Validations
',
));
// Add components to the section
$jFormSection1->addJFormComponentArray(array(
new JFormComponentSingleLineText('validation1', 'required', array('validationOptions' => array('required'),)),
new JFormComponentSingleLineText('validation4', 'required w/ tip', array('validationOptions' => array('required'), 'tip' => 'I have a tip, and I don\'t go away when validation fails, so I can still be helpful.
')),
new JFormComponentSingleLineText('validation3', 'multiple validations', array('validationOptions' => array('alpha', 'required'), 'tip' => 'You can have multiple validations on field, this field is required and must only contain alpha characters, but any combination would work.
Enter some numbers and see what happens, then leave me blank.
')),
new JFormComponentSingleLineText('validation5', 'phone', array('validationOptions' => array('phone'),)),
new JFormComponentSingleLineText('validation6', 'email', array('validationOptions' => array('email'), )),
new JFormComponentSingleLineText('validation7', 'password', array('validationOptions' => array('password'), 'tip' => 'This isn\'t a password field. it only has password validation applied.
' )),
new JFormComponentSingleLineText('validation8', 'match password', array('validationOptions' => array('matches' => 'validation7'), 'tip' => '')),
new JFormComponentSingleLineText('validation9', 'Minimum Length & Integer', array('validationOptions' => array('integer', 'minLength' => 10),)),
new JFormComponentSingleLineText('validation10', 'date', array('validationOptions' => array('date'),)),
new JFormComponentSingleLineText('validation12', 'url', array('validationOptions' => array('url'),)),
new JFormComponentSingleLineText('validation14', 'zip', array('validationOptions' => array('zip'),)),
));
// Add the section to the page
$jFormPage1->addJFormSection($jFormSection1);
// Add the page to the form
$validations->addJFormPage($jFormPage1);
// Set the function for a successful form submission
function onSubmit($formValues) {
$response = array('successJs' => 'validationFormObject.showAlert(\'Do you love jFormer as much as it loves you?\'); $(\'.nextButton\').text(\'Submit\');');
return $response;
}
// Process any request to the form
$validations->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
