当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

angular-validation-match

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 郭炳
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Coverage Status

Angular Validation: Match

Checks if one input matches another. Useful for confirming passwords, emails, or anything.

The match attribute should be set equal to the ng-model value of the field to match.

Demo: http://jsfiddle.net/TheSharpieOne/r6Ltru6c/

Installation

bower install angular-validation-match

Then add validation.match to your angular dependencies

Note: For angular 1.2 or lower use bower install angular-validation-match#1.3

Also: npm install angular-validation-match

Usage

Simple Property Example

Password: <input ng-model="password" type="password" />
Confirm: <input ng-model="passwordConfirm" type="password" match="password" />

Object Property Example

Password: <input ng-model="user.password" type="password" />
Confirm: <input ng-model="user.passwordConfirm" type="password" match="user.password" />

Case insensitive (caseless) Example

Password: <input ng-model="user.password" type="password" />
Confirm: <input ng-model="user.passwordConfirm" type="password" match="user.password" match-caseless="true" />

match-caseless can accept a scoped variable to allow the matching to be toggle-able between case insensitive and case sensitive. Default: false

Not Match Example
Sometimes you want to ensure the values do not match, in that case you can use the not-match flag.This also works in combination with match-caseless (if you want to not match case insensitively).

Password: <input ng-model="user.password" type="password" />
Confirm: <input ng-model="user.passwordConfirm" type="password" match="user.password" not-match="true" />

not-match can accept a scoped variable (true/false) to be toggle-able between matching and not matching. Default: false

Ignore empty Example

Password: <input ng-model="user.password" type="password" />
Confirm: <input ng-model="user.passwordConfirm" type="password" match="user.password" match-ignore-empty="true" />

match-ignore-empty can accept a scoped variable to disable validating an empty input. Default: false

Display Custom Error
If your form and field both are named, you can access the validation result to show/hide messages.

<form name="myForm">
      Password: <input ng-model="user.password" type="password" name="passwordName" />
      Confirm: <input ng-model="user.passwordConfirm" type="password" match="user.password" name="myConfirmField" />
      <div ng-show="myForm.myConfirmField.$error.match">Fields do not match!</div>
</form>

Validate Against the $viewValue shown in the input
The internal value ($modelValue) can differ from the external value ($viewValue) as appears in the input field shown to the user. If your form and field both are named, you can validate against value displayed in the field, even if the field is invalid.

<form name="myForm">
    Password: <input ng-model="user.password" type="password" name="myPasswordField" />
    Confirm: <input ng-model="user.passwordConfirm" type="password" match="myForm.myPasswordField" name="myConfirmField" />
</form>

Note: $viewValues are specific to fields/elements, not models. Different fields with the same ngModel and have different $viewValues. Becuase of this, you need to use the form directive (assigning a name to a form tag) in combination with the specific field's name attribute to specific which field/element you want to match in particular.

  • 以下内容基于Angular 文档中文版的学习 目录 生命周期钩子 视图封装(CSS影响范围) 组件之间的交互   通过输入型绑定把数据从父组件传到子组件   父组件监听子组件的事件   父组件与子组件通过本地变量互动   父级调用 @ViewChild()    父组件和子组件通过服务来通讯 组件样式 内容投影   单插槽内容投影   多插槽内容投影   有条件的内容投影 动态组件 Angular

  • 1,模板驱动验证 每当表单控件中的值发生变化时,Angular 就会进行验证,并生成一个验证错误的列表(对应着 INVALID 状态)或者 null(对应着 VALID 状态)。 你可以通过把 ngModel 导出成局部模板变量来查看该控件的状态。 比如下面这个例子就把 NgModel 导出成了一个名叫 name的变量: <input id="name" name="name" class="fo

  • angular中的表单 使用angular挺长一段时间了,在关于表单的应用方面一直都在使用ng-zorro封装好的表单,至于他的基本概念以及相应的拓展都没有去详细了解,今天趁着空闲研究了一下form表单究竟是个什么东西,以及如何构建一个符合我们需求的自定义校验。 参考:《Angular权威教程》第五章 Angular中的表单,Angular官网 1.表单——既重要又复杂 在web应用中,表单是一个

  • 模板驱动验证 使用模板驱动验证需要依赖于原生的HTML表单验证器 Angular 会用指令来匹配具有验证功能的这些属性。 原生的HTMl验证器主要分两种 通过语义类型来进行定义 通过验证相关的属性来进行定义 语义类型 Input type Constraint description Associated violation <input type="URL"> The value must be

  • 响应式表单 响应式表单概述 响应式表单对表单状态的每一次变更都会返回一个新的状态,这样可以在变化时维护模型的整体性。响应式表单是围绕 Observable 流构建的,表单的输入和值都是通过这些输入值组成的流来提供的,它可以同步访问。 此篇只记录需要注意的知识点,官方文档(中文版)更详细 显示表单控件的值 通过可观察对象 valueChanges,你可以在模板中使用 AsyncPipe 或在组件类中

  •   上一篇文章介绍了serviceWorker是什么以及如何在项目中使用serviceWorker,这一篇着重分析ngsw-worker.js的结构,具体的缓存策略是如何实现的。  一切要从一个中介者开始。ngsw-worker定义了一个Driver,负责worker的初始化,版本更新管理,事件的监听和任务调度。  源头是一个driver class Driver{ constructor

  • According to the Stack Overflow developer survey 2018, Angular is one of the most popular frameworks/libraries among professional developers. So learning it increases your chances of getting a job as

  • https://angular.io/guide/what-is-angular Angular applicaitons: The essentials This section explain the core ideas behind Angular. Understanding these ideas can help you design and build your applicait

 相关资料
  • angular-validation 1.4.5 Client-side Validation should be simple and clean. Don't let Client-side Validation dirty your controller. Setup your Validation on config phase by using some rules (example)

  • Validator::make( array('key' => 'Foo'), array('key' => 'required|in:Foo') ); Validator::extend('foo', function($attribute, $value, $params){}); Validator::extend('foo', 'FooValidator@validate'); Valid

  • jquery.validate.js 是一款执行表单输入信息验证的jQuery插件。要求 jQuery 1.2.6+, compatible with 1.3.x 特点: 安装简单 内置超过20种数据验证方法 直列错误提示信息 可扩展的数据验证方法 使用内置的元数据或插件选项来指定您的验证规则 优雅的交互设计

  • Registering a validator Full featured example Registering a validator When you create a validator, a good idea is to assign it as an alias that will refer to this particular validator function. Handso

  • Official Site : http://jqueryvalidation.org/ Document: http://validation.bassistance.de/documentation/ showcase中的userForm.jsp是最完整的演示。 良好的客户体验 为什么说客户端验证的体验更好,除了不用真正提交form外就知道错误,它还能: 对于remote的验证,是会在inpu

  • Overview 在Service接口(SOAP/REST),一般会使用JSR303 BeanValidator (Hibernate Validator实现)进行验证。 而在Web页面,一般会使用JQuery Validation Plugin实现客户端认证,因为对用户体验比较友好。 如果可能存在恶意用户,会绕过校验的js直接发送Post请求,则需要Spring MVC与Hibernate Va