<script type='text/javascript'>var IsCheckDateOfCtrId=''; $(function() { SetCheckEmptyJS(); });function SetCheckEmptyJS () { $('#txtName').focusout(function () { if ($('#txtName').val() == '') { $('#txtName').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtName').attr('class', 'tbox'); } ClearLblError(); }); $('#txtAddress').focusout(function () { if ($('#txtAddress').val() == '') { $('#txtAddress').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtAddress').attr('class', 'tbox'); } ClearLblError(); }); $('#txtCorp').focusout(function () { if ($('#txtCorp').val() == '') { $('#txtCorp').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtCorp').attr('class', 'tbox'); } ClearLblError(); }); $('#txtContact').focusout(function () { if ($('#txtContact').val() == '') { $('#txtContact').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtContact').attr('class', 'tbox'); } ClearLblError(); }); $('#txtDesScale').focusout(function () { if ($('#txtDesScale').val() == '') { $('#txtDesScale').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtDesScale').attr('class', 'tbox'); } ClearLblError(); }); $('#txtFacilities').focusout(function () { if ($('#txtFacilities').val() == '') { $('#txtFacilities').attr('class', 'RequiredWarningTextBoxBorderStyle'); } else { $('#txtFacilities').attr('class', 'tbox'); } ClearLblError(); }); $('#ddlCateagory').change(function () { if ($(this).val() == '') { $('#sp_ddlCateagory').attr('class', 'RequiredWarningDropDownListBorderStyle'); } else { $('#sp_ddlCateagory').attr('class', ''); } ClearLblError(); }); $('#btnAdd').click(function () { if ($('#txtName').val() == '') { $('#txtName').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtName').attr('class', 'tbox'); } ClearLblError(); if ($('#txtAddress').val() == '') { $('#txtAddress').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtAddress').attr('class', 'tbox'); } ClearLblError(); if ($('#txtCorp').val() == '') { $('#txtCorp').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtCorp').attr('class', 'tbox'); } ClearLblError(); if ($('#txtContact').val() == '') { $('#txtContact').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtContact').attr('class', 'tbox'); } ClearLblError(); if ($('#txtDesScale').val() == '') { $('#txtDesScale').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtDesScale').attr('class', 'tbox'); } ClearLblError(); if ($('#txtFacilities').val() == '') { $('#txtFacilities').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtFacilities').attr('class', 'tbox'); } ClearLblError(); if ($('#ddlCateagory').val() == '') { $('#sp_ddlCateagory').attr('class', 'RequiredWarningDropDownListBorderStyle'); ClearLblError(); } else { $('#sp_ddlCateagory').attr('class', ''); } ClearLblError(); }); $('#btnEdit').click(function () { if ($('#txtName').val() == '') { $('#txtName').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtName').attr('class', 'tbox'); } ClearLblError(); if ($('#txtAddress').val() == '') { $('#txtAddress').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtAddress').attr('class', 'tbox'); } ClearLblError(); if ($('#txtCorp').val() == '') { $('#txtCorp').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtCorp').attr('class', 'tbox'); } ClearLblError(); if ($('#txtContact').val() == '') { $('#txtContact').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtContact').attr('class', 'tbox'); } ClearLblError(); if ($('#txtDesScale').val() == '') { $('#txtDesScale').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtDesScale').attr('class', 'tbox'); } ClearLblError(); if ($('#txtFacilities').val() == '') { $('#txtFacilities').attr('class', 'RequiredWarningTextBoxBorderStyle'); ClearLblError(); } else { $('#txtFacilities').attr('class', 'tbox'); } ClearLblError(); if ($('#ddlCateagory').val() == '') { $('#sp_ddlCateagory').attr('class', 'RequiredWarningDropDownListBorderStyle'); ClearLblError(); } else { $('#sp_ddlCateagory').attr('class', ''); } ClearLblError(); }); }; function ClearLblError() { if(document.getElementById('lblError')!=null) { document.getElementById('lblError').innerText = ''; } } </script>
这是项目里有的js,不知道在哪里,现在我想点击按钮提交,给ddlcategory(下拉列表)注册一个脚本,吧value改成验证“-1”,怎么写?????写在哪里?
我只是来把代码格式化的,我什么都没做。
你是根本就看不懂这段代码么???
什么意思?
@lctk: 因为这段代码看起来还是挺简单的,用的jQuery吧?
@顾晓北:
这是项目里有的js,不知道在哪里,现在我想点击按钮提交,给ddlcategory(下拉列表)注册一个脚本,吧value改成验证“-1”,怎么写?????写在哪里?
@lctk: $('#btnAdd').click你的这个不是给按钮注册点击事件么?当然是在这里面写啊。。。你如果对js一窍不通,你还是找个懂技术的人吧。。。
@顾晓北: 那得怎么写?
@lctk: 你先说你懂不懂js?你如果懂,我就不代劳了。。。