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

angular-validation

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

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)
If you prefer schema over html attributes , try angular-validation-schema (Demo)
And add Validation in your view only.

angularjs 1.2.x support to version angular-validation 1.2.x
angularjs 1.3.x support after version angular-validation 1.3.x
angularjs 1.4.x support after version angular-validation 1.4.x

Requirement

AngularJS 1.2.x (for angular-validation 1.2.x)
AngularJS 1.3.x (for angular-validation 1.3.x)
AngularJS 1.4.x (for angular-validation 1.4.x)

DEMO

http://hueitan.github.io/angular-validation/

Install

Install with npm

npm install angular-validation

or with bower

bower install angular-validation

Using angular-validation

<script src="dist/angular-validation.js"></script>
<script src="dist/angular-validation-rule.js"></script>
angular.module('yourApp', ['validation']);

// OR including your validation rule
angular.module('yourApp', ['validation', 'validation.rule']);

Writing your First Code

<form name="Form">
    <div class="row">
        <div>
            <label>Required</label>
            <input type="text" name="required" ng-model="form.required" validator="required">
        </div>
        <div>
            <label>Url</label>
            <input type="text" name="url" ng-model="form.url" validator="required, url">
        </div>
        <button validation-submit="Form" ng-click="next()">Submit</button>
        <button validation-reset="Form">Reset</button>
    </div>
</form>

Documentation API

Built-in validation in angular-validation-rule

  1. Required
  2. Url
  3. Email
  4. Number
  5. Min length
  6. Max length

5 and 6 require you to pass an inline parameter to set the length limit. Eg, maxlength=6.

Anyone can give a PR for this angular-validation for more built-in validation

Integrating with Twitter Bootstrap

To integrate this package with Bootstrap you should do the following.

Add the following LESS to your project

.ng-invalid.ng-dirty{
    .has-error .form-control;
}

label.has-error.control-label {
    .has-error .control-label;
}

Change the Error HTML to something like:

$validationProvider.setErrorHTML(function (msg) {
       return  "<label class=\"control-label has-error\">" + msg + "</label>";
});

You can add the bootstrap class .has-success in a similar fashion.

To toggle .has-error class on bootstrap .form-group wrapper for labels and controls, add:

angular.extend($validationProvider, {
    validCallback: function (element){
        $(element).parents('.form-group:first').removeClass('has-error');
    },
    invalidCallback: function (element) {
        $(element).parents('.form-group:first').addClass('has-error');
    }
});

License

MIT

CHANGELOG

See release

CONTRIBUTORS

Thank you for your contribution @lvarayut and @Nazanin1369 ❤️
Thanks for all contributors

  • 我由于制作登陆界面,用到了angular-validation,结合ng-cookies,实现记住账户密码的功能。文档是https://github.com/hueitan/angular-validation/blob/master/API.md 该文档挺详细的介绍了angular-validation的使用方式。我因为英文不好,理解的不是很仔细。但是总结了以下的使用经验。 1 首先在模块中注入

  • <input type="number" min="0" max="100" maxlength="5" class="number" ng-model="formData.age" validator="number,required,range" ng-class="{'has-error':orderForm.age.$invalid}" ng-blur="showError(true)"

  •   Angular Validation – Forms Validation with AngularJS 31st March 2015   232   Angular-js Plugins , Form Elements Forms Validation with Angular made easy! Angular-Validation is an angular directive/se

  • 原文出处:https://blog.csdn.net/piaodangdeyouzi/article/details/77477688  延伸阅读:angular2表单验证之ng2-validation学习 (模板驱动表单 和 模型驱动表单 分别说明, 比较详尽) 案例 https://segmentfault.com/a/1190000008631742   (模板驱动表单 和 模型驱动表单 混

  • 1:安装模块 npm install ng2-validation --save 2:配置app.module.ts import { FormsModule, <font color="Red">ReactiveFormsModule</font> } from '@angular/forms'; import {<font color="Red">CustomFormsModule</font

 相关资料
  • Angular 是一款十分流行且好用的 Web 前端框架,目前由 Google 维护。这个条目收录的是 Angular 2 及其后面的版本。由于官方已将 Angular 2 和之前的版本 Angular.js 分开维护(两者的 GitHub 地址和项目主页皆不相同),所以就有了这个页面。传送门:Angular.js 特性 跨平台 渐进式 Web 应用 借助现代化 Web 平台的力量,交付 app

  • 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

  • 即将到来的Angular 2框架是使用TypeScript开发的。 因此Angular和TypeScript一起使用非常简单方便。 Angular团队也在其文档里把TypeScript视为一等公民。 正因为这样,你总是可以在Angular 2官网(或Angular 2官网中文版)里查看到最新的结合使用Angular和TypeScript的参考文档。 在这里查看快速上手指南,现在就开始学习吧!

  • 从头开始创建项目 lint你的代码 运行您的单元测试和端到端测试。 Angular 2 CLI目前只在TypeScript中生成框架,稍后还会有其他版本。

  • 这小节内容是译者加的,因为我认为对于新手而言,学习一个框架是有成本的,特别是对于一个不算简单的技术来说,我希望这篇教程是对新手友好的,所以我首先要让你放心的将时间和精力投入到Angular2 中。那我们先不谈技术细节,先用数据说话。 这里我多说一句,最近看一些文章中谷歌趋势截图,大都没有把范围限定在“编程”上。图中可以看出Vue2非常少,所以在下面比较中不再单独统计。 教程数量 这里我选取的主要是

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 下面给出角度计图表的示例。 配置 (Configurations) 现在让我们看一下所采取的其他配置/步骤。 chart.type 将图表类型配置为基于计量。 将类型设置为“规格”。 var chart = { type: 'guage' }; pane 此类型仅适用于极坐标图和角度