Home  >  Article  >  Backend Development  >  一个有关js的有关问题,请求高手解决

一个有关js的有关问题,请求高手解决

WBOY
WBOYOriginal
2016-06-13 13:49:42638browse

一个有关js的问题,请求高手解决.
我有两个js写的函数:
A函数检验用户输入是不正确,不正确alert( "error ")
具体如下:
function   a()
{
if   (document.form.username.value   !=   ' '){
                          alert( "error ");
                          return   false;  
                  }
}
然后在B函数里调用A函数:
function   B()
{
return   a();
                  form.submit();
}
这样在提交时先调用B函数做别的功能,然后调用A函数,当然我用上面B函数中的方式调用时,username为空时有提示,页面也没有提交,
问题是当username不为空时,页面点提交没有任何响应,也不提交.

当我把B函数中调用A函数的 "return "取掉时,输入为空时提示错误,然后就提交到下一页了,我想要的是有问题时在本页不提交,输入不为空时才提交到下一页,有高手看看这是什么问题????


谢谢

------解决方案--------------------
function B()
{
if(a())form.submit();
return false;
}

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