Home  >  Article  >  Web Front-end  >  Implementing EOS hidden error prompt layer code based on JS_javascript skills

Implementing EOS hidden error prompt layer code based on JS_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:04:071320browse

Without further ado, I will just post the code for you. The specific code is as follows:

//参数为消息提示层对应的对象,通常为表单里的对象
//特别注意:当使用扩展方法里的type=radio或者type=checkbox时,因为当时设置消息提示层的对象为obj.parentElement.parentElement,所以传入的对象也应为其上2级父节点
function hiddenMessageDiv(obj){
var div = obj.Eos_Message;
if(div!=null){
//将该对象从消息数组中移除,防止出现删除标签对象后导致普元Js报错Bug
Eos_All_Message.remove(obj);
//触发提示层的点击事件
div.click();
}
}
//补充添加单选及多选框自定义验证
//通用单选按钮验证 使用例子: extAttr="validateAttr=type=radio;"
function f_check_radio(obj){
//获取相同的name的Radio组
var radioNames = $names(obj.name);
var len = radioNames.length;
for(var i=0;i<len;i++){
if(radioNames[i].checked){
var div = obj.parentElement.parentElement.Eos_Message;
if(div!=null){//去除错误提示div
div.hidden();
}
return true;
}
}
//取parentElement.parentElement的目的是让提示消息显示在后尾
f_alert(obj.parentElement.parentElement,"该项为必选");
return false;
}
//通用多选按钮验证 使用例子: extAttr="validateAttr=type=checkbox;"
function f_check_checkbox(obj){
//获取相同的name的checkbox组
var checkboxNames = $names(obj.name);
var len = checkboxNames.length;
for(var i=0;i<len;i++){
if(checkboxNames[i].checked){
var div = obj.parentElement.parentElement.Eos_Message;
if(div!=null){//去除错误提示div
div.hidden();
}
return true;
}
}
//取parentElement.parentElement的目的是让提示消息显示在后尾
f_alert(obj.parentElement.parentElement,"该项为必选");
return false;
}

The above is the code that the editor introduces to you to implement the EOS hidden error prompt layer based on JS. I hope it will be helpful to everyone!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn