如何使用angularjs当名字字段。(点)以它来验证的形式? [英] How to validate the form using angularjs when the name field has .(dot) in it?

查看:151
本文介绍了如何使用angularjs当名字字段。(点)以它来验证的形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单中我有名字=Customer.Firstname一个输入标签,所以当我指的是angularjs其采取只作为顾客价值和.Firstname会不明身份的名称值。
这里是我的code:

In my form I have a input tag with name="Customer.Firstname" so when i refer to name value in angularjs its taking only customer as the value and .Firstname is going unidentified. Here is my code:

<label class="label_block" ng-hide="ApplicantDetails.Customer.FirstName.$error.required || ApplicantDetails.Customer.FirstName.$error.pattern">FirstName</label>
<span class="clearable">
    <input class="textbox"  type="text" name="Customer.FirstName" ng-model="Customer.FirstName" ng-init="Customer.FirstName='@Model.Customer.FirstName'" value="@Model.Customer.FirstName" ng-pattern="/^([a-zA-Z-']{1,30})$/" required="required"/>
</span>

下面我试图隐藏标签时文本框是我empty.How能做到这一点?

Here am trying to hide the label when the textbox is empty.How can i do that?

推荐答案

您可以使用<一个href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Member_Operators#Bracket_notation\">bracket符号来访问键与圆点

You can use bracket notation to access keys with dot

<label class="label_block" ng-hide="ApplicantDetails['Customer.FirstName'].$error.required || ApplicantDetails['Customer.FirstName'].$error.pattern">FirstName</label>

演示:小提琴

这可以被改写为

<label class="label_block" ng-show="ApplicantDetails['Customer.FirstName'].$valid">FirstName</label>

演示:小提琴

这篇关于如何使用angularjs当名字字段。(点)以它来验证的形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆