• angularJ表单验证


    常用的表单验证指令

    1. 必填项验证

    某个表单输入是否已填写,只要在输入字段元素上添加HTML5标记required即可:

    <input type="text" required /> 

    2. 最小长度

    验证表单输入的文本长度是否大于某个最小值,在输入字段上使用指令ng-minleng= "{number}":

    <input type="text" ng-minlength="5" />

    3. 最大长度

    验证表单输入的文本长度是否小于或等于某个最大值,在输入字段上使用指令ng-maxlength="{number}":

    <input type="text" ng-maxlength="20" />

    4. 模式匹配

    使用ng-pattern="/PATTERN/"来确保输入能够匹配指定的正则表达式

    <input type="text" ng-pattern="/[a-zA-Z]/" />

    5. 电子邮件

    验证输入内容是否是电子邮件,只要像下面这样将input的类型设置为email即可:

    <input type="email" name="email" ng-model="user.email" />

    6. 数字

    验证输入内容是否是数字,将input的类型设置为number:

    <input type="number" name="age" ng-model="user.age" />

    7. URL

     验证输入内容是否是URL,将input的类型设置为url:

    <input type="url" name="homepage" ng-model="user.facebook_url" />

  • 相关阅读:
    IfcDescriptiveMeasure
    IfcBooleanOperator
    IfcKnotType
    IfcCurveOnSurface
    IfcCurvatureMeasure
    IfcBSplineCurveForm
    IfcDoseEquivalentMeasure
    netty系列之:使用UDP协议
    netty系列之:自定义编码和解码器要注意的问题
    netty系列之:内置的Frame detection
  • 原文地址:https://www.cnblogs.com/songyunxinQQ529616136/p/6214619.html
Copyright © 2020-2023  润新知