new Form(id, fields)
This class is used to validate and submit forms client side.
forms are accessible to window by app.formrs[id]
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the id of the form |
fields |
Object | The list of all fields in the form |
Methods
-
displayErrorMessage(text)
-
Display an error message to the form
Parameters:
Name Type Description text
string The message to display -
displayErrors(errors)
-
Display the errors on the form inputs
Parameters:
Name Type Description errors
Object The errors to display, where keys are inputs names, and values the error messages -
isValid()
-
Check the dat of the form
Returns:
- true if the form data is correct, false else- Type
- bool
-
removeErrors()
-
Remove all the form errors
-
reset()
-
Reset the form values
-
setObjectAction(action)
-
Set the object action of the form. The object action can be "register" or "delete", and represents the action that will be performed server side
Parameters:
Name Type Description action
string The action value to set -
submit()
-
Submit the form
Returns:
False- Type
- boolean
-
toString()
-
Display the content of the form
Returns:
The JSON representing the form inputs data- Type
- string
-
valueOf()
-
Get the form data as Object
Returns:
The object containing the form inputs data- Type
- Object