即使在onclick返回true之后,我仍然遇到链接不存在的问题。它在Chrome和Firefox中运行良好。我注意到只有锚的这一特定行为是tag.I现在用引导的反应(不知道这是影响..)即使在onclick =“return true;”之后,IE11并没有跟踪链接
样品:
<form>
<a id="SignonButton" class="SignonButton" HREF="https://www.google.com" onClick="return true;">
<button type="button" class="btn btn-primary" id="button1" name="button1">Inside form doesnt work</button>
</a>
</form>
<a id="SignonButton" class="SignonButton" HREF="https://www.google.com" onClick="return true;">
<button type="button" class="btn btn-primary" id="button1" name="button1">Outside form works</button>
</a>
@TJ确实是这样,它的工作。 其实我改造现有一个形式,使之响应的形式具有两个动作和两个输入元素 1. HREF =“使用Javascript:transferRequest()” 2.的onClick =“validateRequest()”
形式具有两个输入元素input1:email和input2:密码。
什么我可以从现有代码不解的是,validateeRequest()验证电子邮件方式([email protected])和密码alphanum模式并返回true
如果两个模式相匹配。
验证请求检查两个文本框以确认输入的文本相匹配的图案或没有(不验证只是检查,如果模式匹配与否,转印
请求实际上两个文本传送,因为它是服务器)。
建议使用<a>
为按钮是正确的,或者我需要添加验证方法到按钮 我不允许完全修改网站,只是将其转换为响应。
<div>
<label for="email">Email</label>
<input type="TEXT" size="16" maxlength="19" autocomplete="OFF">
</div>
<div>
<label for="Password" >Password</label>
<input type="PASSWORD" size="16" maxlength="19" autocomplete="OFF>
</div>
<div>
<a id="SignonButton" HREF="javascript:transferRequest('verify')" onClick="return ValidateRequest('Verify');">
<button type="button" class="btn btn-primary" id="button1" name="button1">Inside form doesnt work</button>
</a>
</div>
</form>
function transferRequest()
{
var form = document.loginForm;
document.loginForm.submit();//submits to local exchange server
//some crazy validation
}
function validateRequest()
{
// code to check if the email input follows pattern ([email protected]) or not
// code to check if the password has alphanum as pattern or not
//return true if both pattern matches
}
可能是由于一个互动的元素(''