Gets or sets the jqxForm's padding.
$('#sampleForm').jqxForm({
padding: { left: 10, top: 10, right: 10, bottom: 10 }
});
Gets or sets the jqxForm's backgroundColor.
$('#sampleForm').jqxForm({
backgroundColor: '#fafafa';
});
Gets or sets the jqxForm's borderColor.
$('#sampleForm').jqxForm({
borderColor: '#fafafa';
});
Gets or sets the jqxForm's value.
var sampleValue = {
firstName: 'John',
lastName: 'Scott',
address: '1st Ave SW',
company: 'N/A',
city: 'San Antonio',
state: 'Texas',
zip: '78209'
};
$('#sampleForm').jqxForm({
template: template,
value: sampleValue,
backgroundColor: '#fafafa',
padding: { left: 10, top: 10, right: 10, bottom: 10 }
});
Gets or sets the jqxForm's template. Each object in the template, represents a Form row. Each row can have one field with label or multiple fields(if the current object's columns property is defined).
Template options:
var template = [
{
bind: 'firstName',
type: 'text',
label: 'First name',
required: true,
labelWidth: '80px',
width: '250px',
info: 'Enter first name',
infoPosition: 'right'
},
{
bind: 'lastName',
type: 'text',
label: 'Last name',
required: true,
labelWidth: '80px',
width: '250px',
info: 'Enter last name'
},
{
bind: 'company',
type: 'text',
label: 'Company',
required: false,
labelWidth: '80px',
width: '250px'
},
{
bind: 'address',
type: 'text',
label: 'Address',
required: true,
labelWidth: '80px',
width: '250px'
},
{
bind: 'city',
type: 'text',
label: 'City',
required: true,
labelWidth: '80px',
width: '250px'
},
{
bind: 'state',
type: 'option',
label: 'State',
required: true,
labelWidth: '80px',
width: '250px',
component: 'jqxDropDownList',
options: [
{ value: 'California' },
{ value: 'New York'},
{ value: 'Oregon'},
{ value: 'Illinois'},
{ value: 'Texas'}
]
},
{
bind: 'zip',
type: 'text',
label: 'Zip code',
required: true,
labelWidth: '80px',
width: '250px'
},
{
type: 'blank',
rowHeight: '10px'
},
{
columns: [
{
type: 'button',
text: 'Sign up',
width: '90px',
height: '30px',
rowHeight: '40px',
columnWidth: '50%',
align: 'right'
},
{
type: 'button',
text: 'Cancel',
width: '90px',
height: '30px',
rowHeight: '40px',
columnWidth: '50%'
}
]
}
];
var sampleValue = {
firstName: 'John',
lastName: 'Scott',
address: '1st Ave SW',
company: 'N/A',
city: 'San Antonio',
state: 'Texas',
zip: '78209'
};
$('#sampleForm').jqxForm({
template: template,
value: sampleValue,
backgroundColor: '#fafafa',
padding: { left: 10, top: 10, right: 10, bottom: 10 }
});
Binds to the 'formDataChange' event.
sampleForm.on('formDataChange', function (event) {
var args = event.args;
var newValue = args.value;
var previousValue = args.previousValue;
for (var i in newValue) {
var newInputValue = newValue[i]; // current input's value.
var previousInputValue = previousValue[i]; // previous input's value.
}
});
Binds to the 'buttonClick' event.
sampleForm.on('buttonClick', function (event) {
var args = event.args;
var text = args.text // clicked button's text.;
var name = args.name // clicked button's name.;
});
Refreshes the Form value and re-renders it.
$('#sampleForm').jqxForm('refresh');
$('#sampleForm').jqxForm('destroy');
$('#sampleForm').jqxForm('hideComponent', 'submitButton');
$('#sampleForm').jqxForm('showComponent', 'submitButton');
Sets or gets the value of the object to bind to the form.
Submits the form.
var btn = sampleForm.jqxForm('getComponentByName', 'submitButton');
btn.on('click', function () {
// function: submit
// arg1: url
// arg2, optional: target, default is _blank
// arg3, optional: submit method - GET or POST, default is POST
sampleForm.jqxForm('submit', "https://www.jqwidgets.com/form_demo/", "_blank", 'POST');
});
Gets a form input element by name.
var btn = sampleForm.jqxForm('getComponentByName', 'submitButton');
btn.on('click', function () {
// function: submit
// arg1: url
// arg2, optional: target, default is _blank
// arg3, optional: submit method - GET or POST, default is POST
sampleForm.jqxForm('submit', "https://www.jqwidgets.com/form_demo/", "_blank", 'POST');
});