Thursday, 18 July 2013

jTable Add Record Form Validation

Before Perform jQuery Validation Coding, We need to include the jQuery-validation javascript resource file in our Application.

Lest Consider the Following..
We have to enter Country Table with country name, country code.

Coding To perform the Validation....

$('#CountryTableContainer').jtable({
                title: 'Countries List',
                paging: true,
                sorting: true,
                defaultSorting: 'CountryCode ASC',
                selecting: true, //Enable selecting
                multiselect: true, //Allow multiple selecting
                selectingCheckboxes: true, //Show checkboxes on first column
                selectOnRowClick: false, //Enable this to only select using checkboxes
                actions: {
                    listAction: '/Pages/Country.aspx/CountryListByFilter', //List the Data
                    createAction: '/Pages/Country.aspx/CreateCountry', //This is for Create a New Country Details
                    updateAction: '/Pages/Country.aspx/UpdateCountry', // This is for Update the Records
                    deleteAction: '/Pages/Country.aspx/DeleteCountry' //This is for Delete the Records
                },
                fields: {
                    CountryIdentity: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    CountryCode: {
                        title: 'Country Code',
                        width: '33%'
                    },
                    CountryName: {
                        title: 'Country Name',
                        width: '33%'
                    }
                },
                //Initialize validation logic when a form is created
                formCreated: function (event, data) {
                    data.form.find('input[name="CountryCode"]').addClass('validate[required]');
                    data.form.find('input[name="CountryName"]').addClass('validate[required]');
                    data.form.validationEngine();
                },
                //Validate form when it is being submitted
                formSubmitting: function (event, data) {
                    return data.form.validationEngine('validate');
                },
                //Dispose validation logic when form is closed
                formClosed: function (event, data) {
                    data.form.validationEngine('hide');
                    data.form.validationEngine('detach');
                }
            });

Get More Knowledge, click the Following Link
https://github.com/posabsolute/jQuery-Validation-Engine

 Add Record




Edit Record




No comments:

Post a Comment