form and cursor validation
----------------------------
form validation
----------------
$('#DetailsectionBOMform').validate({
highlight: function (element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function (element) {
$(element).closest('.form-group').removeClass('has-error');
},
errorElement: 'span',
errorClass: 'help-block',
errorPlacement: function (error, element) {
if (element.parent('.input-group').length) {
//error.insertAfter(element.parent());
} else {
// error.insertAfter(element);
}
}
});
cursor validation
------------------
function BomFormCurr() {
$('#BOMComboForm').find(':text,:radio,:checkbox,select,textarea').each(function () {
if (!this.readOnly && !this.disabled && this.required &&
$(this).parentsUntil('form', 'div').css('display') != "none" && $(this).css('display') != "none") {
if (this.value.trim() == "") {
this.focus(); //Dom method
this.select(); //Dom method
return false;
}
}
});
}
example see below
---------------------
/*Save SaveBOMGrid Save function starts here*/
function SaveBOMGridtable() {
try {
$('#BtnSave').click(function () {
$('#pageloaddiv').show();
if ($("#BOMComboForm").valid()) {
here u can write the logic
} else { BomFormCurr(); }
});
}
catch (ex) {
}
}
/*Save SaveBOMGrid Save function end here*/
2:18 AM
Share:
0 comments: