## Properties

Name | Type | Default
--- | --- | ---
rules | Array | []
Sets jqxValidator rules. Format of a single rule is as follows:
    { input: 'selector-of-the-input',
        message: 'Custom message on error',
        action: 'Custom action (keyup, change...etc)',
        rule: 'Build rule (ssn, phone, email...) or custom function',
        position: 'Position of the hint (format pos:x,y)',
        hintRender: 'Function for hint rendering' }
Let's look at all different properties of a single rule. The input property must be selector of the input you want to validate (we recommend to use ids - example: '#userInput'). The message property is the custom message which will popup, on validation error, for the current rule. Action is a string which is the event on which you want to validate the input (for example click, mouseup, blur, keyup...). The rule property is defining the way you want to validate the input. In jqxValidator there are built in rules like: 'ssn', 'email', 'required', 'phone', 'zipCode', 'maxLength=len', 'minLength=len', 'length=max,min'. In the last three validation rules the strings after the "=" are the rule parameters, for example: 'maxLength=13'. You can also write a function for a custom rule. 'ssn' - 'Social Security Number' Requires input like: ___-__-____ 'email' - requires valid e-mail address. 'required' - requires a CheckBox or Radio Button to be checked or any value to be entered in an Input. 'phone' - requires input like: (___)___-____ 'zipCode' - requires a valid zip code like: ___-__-____ 'maxLength=len' - restricts the maximum input characters to 'len'. 'minLength=len' - restricts the minimum input characters to 'len' 'length=min,max' - restricts the input length to a specific range. Hint positions are as follows: 'left', 'right', 'top', 'bottom', 'bottomcenter', 'topcenter', 'topleft', 'topright', 'bottomleft', 'bottomright'. If you wish to set also an offset you can pass the position like: 'topleft:15,3'. This is going to position your message popup in top-left of the input with offset: left - 15px, top - 3px. The last property is hintRender. This is function used for hint rendering. If you don't pass one the default is going to be used. Notice that the position and hintRender are optional. If you don't set them the default values are going to be used. #### Code examples Initialize a jqxValidator with the `rules` property specified.
    $('#form').jqxValidator( { rules: [{ input: '#passwordInput',
                                            message: 'The password is required!',
                                            action: 'keyup',
                                            rule: 'required' },
                                        { input: '#passwordInput',
                                            message: 'Your password must be between 4 and 12 characters!',
                                            action: 'keyup',
                                            rule: 'length=4,12' }] } );
Custom Rule Definition. The function returns true or false depending on whether the input is correct or not.
    { input: '#birthInput', message: 'Your birth date must be between 1/1/1900 and 1/1/2012.', action: 'valuechanged', rule: function () {
        var date = $('#birthInput').jqxDateTimeInput('value');
        var result = date.dateTime.getFullYear() >= 1900 && date.dateTime.getFullYear() <= 2012;
        return result;
    }
scroll | Boolean | true
Sets whether the jqxValidator will scroll the page to the first invalid input. #### Code examples Initialize a jqxValidator with the `scroll` property specified.
    $('#form').jqxValidator( { scroll: false } );
focus | Boolean | true
Sets whether the jqxValidator will focus the first invalid input. #### Code examples Initialize a jqxValidator with the `focus` property specified.
    $('#form').jqxValidator( { focus: false } );
scrollDuration | Number | 300
Sets or gets the scroll duration, to the first invalid input, when the validation fails. #### Code examples Initialize a jqxValidator with the `scrollDuration` property specified.
    $('#form').jqxValidator({ scrollDuration: 500 });
scrollCallback | Function | null
Sets a callback function which will be executed when the scroll, to the first invalid input, ends. #### Code examples Initialize a jqxValidator with the `scrollCallback` property specified.
    $('#form').jqxValidator({ scrollCallback: function () { alert('Scrolled'); } });
position | String | 'right'
Gets or sets the default position of the hints. #### Code examples Initialize a jqxValidator with the `position` property specified.
    $('#form').jqxValidator({ position: 'topcenter' });
arrow | Boolean | true
Sets or gets whether the arrow of the hints will be shown. #### Code examples Initialize a jqxValidator with the `arrow` property specified.
    $('#form').jqxValidator( { arrow: false } );
animation | String | 'fade'
Sets or gets the animation of showing, hiding the hints. Possible values are 'fade' and 'none'. #### Code examples Initialize a jqxValidator with the `animation` property specified.
    $('#form').jqxValidator({ animation: 'none' });
animationDuration | Number | 150
Gets or sets the duration of the animation used for showing/hiding the hints. #### Code examples Initialize a jqxValidator with the `animationDuration` property specified.
    $('#form').jqxValidator({ animationDuration: 300 });
closeOnClick | Boolean | true
Sets or gets whether the hints will be closed when the user click on them. #### Code examples Initialize a jqxValidator with the `closeOnClick` property specified.
                                $('#form').jqxValidator({ closeOnClick: false });
onError | Function | null
Sets callback which will be called on validation error. #### Code examples Initialize a jqxValidator with the `onError` property specified.
    $('#form').jqxValidator({ onError: function () { alert('You havent filled the form correctly!'); } });
onSuccess | Function | null
Sets the callback which will be executed on success. #### Code examples Initialize a jqxValidator with the `onSuccess` property specified.
    $('#form').jqxValidator({ onSuccess: function () { alert('Success!'); } });
## Events
validationError | Event |
validationError is triggered when the form is validated with some errors. #### Code examples Bind to the validationError event.
    $('#form').bind('validationError', function (event) { // Some code here. });
validationSuccess | Event |
validationError is triggered when the form is validated whithout any errors. #### Code examples Bind to the validationSuccess event.
    $('#form').bind('validationSuccess', function (event) { // Some code here. });
## Methods
validate | Method |
Validating the whole form. #### Code example Invoke the validate method.
    $('#form').jqxValidator('validate', element);
validateInput | Method |
Validates a single input. This method accepts a single parameter which is selector of the input you want to validate. Notice that this selector should be the same like the one you've passed in the rules array. #### Code example Invoke the validateInput method.
    $('#form').jqxValidator('validateInput', '#passwordInput');
hideHint | Method |
Hide all hints for a specific input. #### Code example Invoke the hideHint method.
    $('#form').jqxValidator('hideHint', '#passwordInput');
hide | Method |
Hiding all hints for the current form. #### Code example Invoke the hide method.
    $('#form').jqxValidator('hide');
updatePosition | Method |
Updating the positions of all hints. This is useful for example on window resize. #### Code example Invoke the checkItem method.
    $('#form').jqxValidator('updatePosition');