Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS在输入未完成时阻止提交';t验证_Javascript_Html_Angularjs_Forms - Fatal编程技术网

Javascript AngularJS在输入未完成时阻止提交';t验证

Javascript AngularJS在输入未完成时阻止提交';t验证,javascript,html,angularjs,forms,Javascript,Html,Angularjs,Forms,如果输入尚未验证,我将尝试阻止表单提交 这是我的密码: html <form method="post" enctype="multipart/form-data" ng-submit="insertCustomer(insertProfile)" id="form-customer" name="form" class="css-form" novalidate > <div class="row"> <div class="col-md-7">

如果输入尚未验证,我将尝试阻止表单提交

这是我的密码:

html

<form method="post" enctype="multipart/form-data" ng-submit="insertCustomer(insertProfile)" id="form-customer" name="form" class="css-form" novalidate >
<div class="row">
    <div class="col-md-7">
        <label>Full Name* 
        <span class="required-label" ng-show="form.$submitted || form.full_name.$touched">
            <span ng-show="form.full_name.$error.required">(Full Name is required.)</span>
        </span>
        </label>
        <input type="text" ng-model="insertProfile.full_name" name="full_name" class="form-control" required="" />
    </div>
</div>
</form>

<button type="submit" form="form-customer"
        class="btn btn-primary pull-right" id="cmd_insert_customer" ng-show="tab == 3">
Insert Customer
</button>

全名*
(需要全名。)
插入客户

我尝试过使用
ng submit=“form.$valid&&insertCustomer(insertProfile)”
。。。如果输入为空,则表单不会提交,但当我输入值时。。。它仍然没有提交…

删除以下内容,因为您将使用角度法提交表单

method="post" enctype="multipart/form-data"
此外,只有在某些情况下才能防止违约行为


下面是一个更好的示例

将表单传递给insertCustomer函数,并检查函数的有效性

<form method="post" enctype="multipart/form-data" ng-submit="insertCustomer(form)" id="form-customer" name="form" class="css-form" novalidate >
<div class="row">
    <div class="col-md-7">
        <label>Full Name* 
        <span class="required-label" ng-show="form.$submitted || form.full_name.$touched">
            <span ng-show="form.full_name.$error.required">(Full Name is required.)</span>
        </span>
        </label>
        <input type="text" ng-model="insertProfile.full_name" name="full_name" class="form-control" required="" />
    </div>
</div>
</form>

<button type="submit" form="form-customer"
        class="btn btn-primary pull-right" id="cmd_insert_customer" ng-show="tab == 3">
Insert Customer
</button>
$scope.insertCustomer = function(form){
    if(form.$invalid){
        return;
    }
    //form submit code....
}

希望它能起作用。

对不起,我的坏人。。。它没有提交,因为还需要其他输入。。。。对不起我的坏人…对不起我的坏人。。。它没有提交,因为还需要其他输入。。。。对不起,我的错。。。