简体   繁体   English

表单提交按钮不与AngularJs一起使用

[英]Form submit button not working with AngularJs

I've a problem with my form. 我的表格有问题。 I want to make standard PHP form but AngularJS is blocking the "Submit" button. 我想制作标准的PHP表单,但AngularJS阻止了“提交”按钮。

When I click the "Submit" button, it returns some errors in console. 当我单击“提交”按钮时,它会在控制台中返回一些错误。 And remember I don't want to dynamically submit. 请记住,我不想动态提交。

The error is: 错误是:

An invalid form control with name='' is not focusable. 名称=''的无效表单控件不可聚焦。

This example 这个例子

<body ng-app="mainApp">
    <form action="post.php" method="post">
        <div ng-controller="MainCtrl">
            <label for="titlex">Title</label>
            <input id="titlex" class="form-control" type="text" maxlength="75" min="10" name="titlex" required>
        </div>
        <input type="submit" value="Send">
    </form>
</body>

This issue pops up in different cases: 在不同情况下会弹出此问题:

  • You have a hidden form element that has a required attribute for validation. 您有一个隐藏的表单元素,它具有验证required属性。
  • You hide an form element before send your data. 您在send数据之前隐藏表单元素。
  • Some required form elements does not have a name attribute. 某些必需的表单元素没有name属性。
  • Your submit input does not have a name attribute. 您的提交input没有name属性。

You can try to add a name attribute to your submit input: 您可以尝试在提交输入中添加name属性:

<input type="submit" value="Send" name="send">

or you can setup your form to be not validated by the browser mechanics by using 或者您可以设置您的表单,以便浏览器机制不使用

<form name="myform" novalidate>

Try adding name attribute in input tag. 尝试在输入标记中添加name属性。 Only form elements with a name attribute will have their values passed when submitting a form. 只有具有name属性的表单元素才会在提交表单时传递其值。

<input type="submit" value="Send" name="send">

Hope this solves your problem. 希望这能解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM