jQuery Form

For this plugin we have extended the jQuery Form plugin.

Thank you Mike Alsup for jQuery Form.
Visit jQuery Form website

BW Form

The extended version includes handling validation and extended form element attributes for further functions. For extended real-time validation functionality see BW Validation.

/config/config.static.php

 
$jsPlugins = array(
	"all"=>array("form")
);
	 

In PHP your can serve your response up as JSON encoded data.

Example PHP response

 
$response = array(
	"success"=>false,
	"message"=>"This form doesn't work!",
	"validation"=>array(
		"htmlInputName"=>"This input means nothing to me"
	)
);
echo json_encode($response);
	 

Example Javascript usage

 
$("form").bwForm(options);
	 

bwForm Options

To initialise the extended version, these are your options.

Variable/Key
Type
Default
Description
confirmNotice
string
false (bool)
this string will display a confirmation notice before submitting the form
successNotice
string
false (bool)
an alert to display if the response shows the submission is successful
successRedirect
string
false (bool)
if the the response from your submission is successful, the user will be redirected to this URL
reset
boolean
false
clear
boolean
false
errorClass
string
'bw-form-error'
a class to add to input (or wrapper if using BW Inputs) to show the input was erronious

bwForm options.functions

These are functions that are run for specific events

Variable/Key
Type
Default
Description
beforeSerialize
function
false (bool)
beforeSubmit
function
false (bool)
success
function
false (bool)
your function to be run on the extended version of the success function. bwForm also checks the response for messages and validation responses. see also jQuery Form - success
error
function
false (bool)
callback function to be invoked upon error. Passes just the jQuery form object back. Errors are outputted as a warning in your console.
fail
function
false (bool)
a function to be run if the form failed due to the response given

bwForm options.submit

These are some options to automate your form's submit button

Variable/Key
Type
Default
Description
waitText
string
false (bool)
if set, your submit button's text will change to this while your form is submitting
waitClass
string
false (bool)
if set, your submit button will gain this class while your form is submitting
successText
string
false (bool)
if set, your submit button's text will change to this when your form is successful
successClass
string
false (bool)
if set, your submit button will gain this class when your form is successful