You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.5集成Google隐形验证码表单无法提交,控制台报submit非函数错误

解决Laravel 5.5集成Google隐形验证码时submit is not a function错误

Hey Douglas, sorry to hear you've been stuck on this reCAPTCHA issue for a day—let's fix this quickly!

The root cause here is likely a naming conflict with your submit button, which is overriding the form's native submit() method. Here's the breakdown and fix:

问题核心原因

Your submit button has name="submit":

<button class="btn theme-btn" name="submit" type="submit">Enviar consulta</button>

Browsers automatically map form elements with name attributes to properties on the form object. When you name a button submit, it replaces the form's built-in submit() function with a reference to the button element itself. That's why calling _captchaForm.submit() throws the "not a function" error—you're trying to run a button element like a function!

快速修复方案

Simply rename the button's name attribute to something that doesn't clash with the form's native methods, like submit-btn:

<form action="{{ route('post-contact') }}" method="post"> 
    {{ csrf_field() }} 
    <div class="form-group"> 
        <label>Nombre:</label> 
        <input type="text" class="form-control" placeholder="Nombre" name="name" /> 
    </div> 
    <div class="form-group"> 
        <label>Email:</label> 
        <input type="email" class="form-control" placeholder="Email" name="email" /> 
    </div> 
    <div class="form-group"> 
        <label>Mensaje:</label> 
        <textarea class="form-control height-120" placeholder="Mensaje" name="msg"></textarea> 
    </div> 
    @captcha('en') 
    <div class="form-group"> 
        <button class="btn theme-btn" name="submit-btn" type="submit">Enviar consulta</button> 
    </div> 
</form>

额外验证点

Since you already confirmed all bindings are working (Checking element binding of _captchaForm... true), this change should resolve the error immediately. If you still run into issues after this, double-check:

  • The @captcha('en') directive is rendering the reCAPTCHA script correctly (inspect the page source to verify it's adding the necessary JS and hidden fields)
  • There are no other elements with id="submit" or name="submit" elsewhere in the form or page

This is a super common gotcha with form submissions, so don't feel bad about missing it—happens to the best of us!

内容的提问来源于stack exchange,提问作者Douglas Roos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:08:00