Adhikar Patil

Adhikar Patil

  • NA
  • 481
  • 128.3k

How to set required attribute on checked event in jqgrid

Jan 27 2019 2:12 AM
Hello,
        Here is my code How to Set Required attribute to DefectNo when  IsElementDefect  is checked and remove required attribute on IsElementDefect Unchecked.
 colModel: [
{label: 'Is Defect', name: 'IsElementDefect', width: 130, align: 'center', edittype: "checkbox",
hidden: true, editable: true, editrules: { edithidden: true }, hidedlg: true}
editoptions: {
text: "IsElement:IsDefect", value: '1:0',
dataEvents: [
{
type: 'change', fn: function (e) {
if ($('#IsElementDefect').is(':checked')) {
$('#tr_DefectNo').show();
$('#tr_DefectNo').attr('required', 'required');
$('#tr_DefectNo').prop('required');
}
else {
$('#tr_DefectNo').hide();
$('#tr_DefectNo').removeAttr('required');
}
}
}]
}, formatter: "checkbox", formatoptions: { disabled: false }, sortable: false
},
 
 
{label: 'Element No', name: 'ElementNo', width: 130, editable: true, stype: "select", edittype: "select", editrules: { required: true }},
 
{label: 'Defect No', name: 'DefectNo', width: 130, editable: true, stype: "select", edittype: "select", editrules: { required: true }}, 
 
 
Please provide me solution as soon as possible 
 

Answers (1)