我已经使用javascript动态创建了元素。元素有多种类型(例如kendoComboBox,kendoTextBox,datePicker等)。我想在用户尝试保存数据时按照声明验证每个元素。
$.each(data, function(key, frmelements) {
if (i <= 3) {
//console.log(i);
if (i == 1) {
frmString += '<div class="col-md-12" style="padding-left:0px">';
}
frmString += '<div class="col-md-4">';
frmString += frmelements.property_name;
frmString += ':<br />';
if (frmelements.property_name == "PSS" && frmelements.property_type_id == 1) {
pss_value_id = '#prop_' + frmelements.propertyId + '_id';
} else if (frmelements.property_name.includes("Style") && frmelements.property_type_id == 1) {
style_value_id = '#prop_' + frmelements.propertyId + '_id';
}
if (frmelements.property_type_id == 1) { //Text Box
var prop_value_id = 'prop_' + frmelements.propertyId + '_id';
var prop_value_name = 'prop_' + frmelements.propertyId + '_name';
// Check If numeric // Added by tanver instantly
if (fabricnumericText.includes(frmelements.property_name)) {
frmString += '<input style="width:80%" class="k-textbox" onblur="handleChange(this);" type="number" max="100" min="0" id="' + prop_value_id + '" name="' + prop_value_id + '_input">';
fabricids += "#" + prop_value_id + ",";
} else if (addFabricnumericText.includes(frmelements.property_name)) {
frmString += '<input style="width:80%" class="k-textbox" onblur="handleChange(this);" type="number" max="100" min="0" id="' + prop_value_id + '" name="' + prop_value_id + '_input">';
addFabricids += "#" + prop_value_id + ",";
} else {
frmString += '<input style="width:80%" class="k-textbox" type="text" id="' + prop_value_id + '" name="' + prop_value_id + '_input">';
}
// Check end
}
}):