调用函数提交按钮
我想在另一个函数validateForm中调用函数notEmpty。但是我需要通过这个函数的选择器并在提交表单之后。调用函数提交按钮
请看:
$("#accountemail").blur(notEmpty);
$("#submit_account").click(validateForm);
function notEmpty()
{
if($(this).val() == "")
{
// Send a warning message
warn($(this), "notEmpty");
return false;
}
else
{
// Remove a warning message
unwarn($(this), "notEmpty");
return true;
}
}
function validateForm()
{
// How i can call the function passing the selector and after submit the form?
}
加入一个参数传递给您的validateForm功能。当你将函数名称作为参数传递给clcik处理函数时,jQuery将返回函数中的元素
$("#submit_account").click(validateForm);
function validateForm()
{
/* $(this) will be the same as $("#submit_account")*/
}
的元素ID不会'element'包含事件对象而不是第一个片段中的元素? – 2012-03-08 15:21:18
oops..asleep at wheel..updated ..谢谢@Kevin B – charlietfl 2012-03-08 15:22:18
你可以更精确吗?我试过$(“#accountemail”)。notEmpty();但doens't没有工作 – KillCloud 2012-03-08 16:56:55
什么是“选择器”? – 2012-03-08 14:45:33
表单 – KillCloud 2012-03-08 15:06:00