function userid_validation(uid, mx, my) {
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx) {
alert("User Id should not be empty / length be between " + mx + " to " + my);
uid.focus(); //is this focus will be on alert box?
return false; //what is use of this false ?
}
return true; //what is use of this true?
}
问问题
190 次
2 回答
0
我想它可以防止事件冒泡。防止链接和表单的标准行为(防止重定向和提交)是常见的做法。
于 2012-08-31T07:44:32.010 回答
0
如果没有看到代码是从哪里调用的,就不能完全确定......但很可能它是从 DOM0 事件处理程序(由 分配的<element>.onclick=
)调用的
false 将阻止默认操作发生,而 true 将允许它发生。
function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx)
{
alert("User Id should not be empty / length be between "+mx+" to "+my);
uid.focus(); //is this focus will be on alert box?
return false; //what is use of this false ?
}
return true; //what is use of this true?
}
于 2012-08-31T07:43:05.933 回答