您现在的位置是:首页 > 电脑技术查询 > web开发

一段JS验证代码,可有高人来简化下解决方法

编辑:chaxungu时间:2022-10-02 23:14:20分类:web开发

一段JS验证代码,可有高人来简化下
JScript codefunction toDelete(id){ var id = document.getElementById('id').value; var orgId = document.getElementById('orgId').value; var documentOrgId = document.getElementById('documentOrgId').value; var parentId = document.getElementById('parentId').value; var documentTypeList = document.getElementById('documentTypeList').value; var documentList = document.getElementById('documentList').value; if (id == '') { alert("请选择目录"); } else if (orgId == documentOrgId) { if (parentId == '') { alert("根目录不能删除"); } else if (documentTypeList == '[]' && documentList == '[]' ) { if(confirm("您真的要删除此目录吗")) { window.location='doDeleteDocumentType.do?documentType.id='+id; } else { return; } } else if (documentTypeList == '[]') { alert("目录下有资料,不能删除"); } else if (documentList == '[]') { alert("目录下有子目录,不能删除"); } else { alert("目录下有子目录和资料,不能删除"); } } else { alert("非本公司添加,不能删除"); }}

------解决方案--------------------
探讨

LZ要简化 可以应用Jquery

这样document.getElementById('id').value;->$("#id").val();

------解决方案--------------------
咋不用jquery写一个呢?