Hello,
I listen to the onChange event in the Form.
in the onChange event, I validate the form, which moves focus on the first input field.
How can I switch it off? Possibly by setting focusInvalid: false;
I need validation on change because, I enable the save button when the form is valid, otherwise, it is disabled.
See the code:
forma.dialog({
title: 'შეტყობინების გაგზავნა',
width: 870,
height: 300,
modal: false,
resizable: true,
closeAnimation: 'hide',
minimize: 'animate',
collapsible: true,
minimizable: true,
maximizable: true,
href: false,
bodyCls: 'kk f-column',
toolbar: buildToolbar([{
id: 'save-btn',
text: 'შექმნა',
iconCls: 'icon-save',
plain: true,
type: 'linkbutton',
separator: true,
disabled: true,
onClick: function() {
forma.find('form').submit();
}
}, {
text: 'დახმარება',
iconCls: 'icon-help',
plain: true,
type: 'linkbutton',
separator: false,
onClick: function() {
$.messager.alert('ბილეთის შექმნა: დახმარება', 'ბილეთის შექმნისას დეტალურად მიუთითეთ საკითხის აღწერილობა. გაითვალისწინეთ, ბილეთის დასახელება ხილვადი იქნება მომხმარებლისთვის, ხოლო, აღწერილობა - არა.', 'info');
}
}]),
onOpen: function()
{
forma.find('form').form({
iframe: false,
method: 'POST',
url: '/api-submitCustomerCustomSMS',
queryParams: {
customerId: customer_id,
},
onSubmit: function() {
$.messager.progress({
title: 'მიმდინარეობს მონაცემების შენახვა',
msg: 'გთხოვთ, დაელოდოთ...',
interval: 0
});
var isValid = forma.find('form').form('validate');
if (!isValid) {
$.messager.progress('close'); // hide progress bar while the form is invalid
}
return isValid; // return false will stop the form submission
},
onProgress: function(percent) {
var bar = $.messager.progress('bar'); // get the progressbar object
bar.progressbar('setValue', percent); // set new progress value
},
success: function(data) {
$.messager.progress('close'); // hide progress bar while submit successfully
try {
var data = JSON.parse(data);
if (data.success) {
$.messager.alert('წარმატებით შესრულდა', data.message);
var opts = $(this).form('options');
opts.originalData = $(this).serialize();
forma.dialog('panel').find('#save-btn').linkbutton('disable');
$(this).form('resetDirty');
} else if (data.error) {
$.messager.alert('შეცდომა', data.message, 'error');
}
} catch (e) {
$.messager.alert('შეცდომა', 'სერვერთან დაკავშირება ვერ ხერხდება.', 'error');
}
CustomerTabPanel.find('#customer_smsHistory').datagrid('reload');
},
onChange: function (target) {
var isValid = forma.find('form').form('validate');
if (!isValid) {
forma.dialog('panel').find('#save-btn').linkbutton('disable');
}
else
{
forma.dialog('panel').find('#save-btn').linkbutton('enable');
}
}
});
forma.find('#scheduleTime').textbox('hide');
},
onClose: function() {
$(this).window('destroy').remove();
},
});