zoukankan      html  css  js  c++  java
  • Adding Validation to our Album Forms 添加类属性的一些验证特性

    Adding Validation to our Album Forms

    We’ll use the following Data Annotation attributes:

    • Required – Indicates that the property is a required field
    • DisplayName – Defines the text we want used on form fields and validation messages
    • StringLength – Defines a maximum length for a string field
    • Range – Gives a maximum and minimum value for a numeric field
    • Bind – Lists fields to exclude or include when binding parameter or form values to model properties
    • ScaffoldColumn – Allows hiding fields from editor forms
    示例:
    [
    ScaffoldColumn(false)] //这个就是是否自动插入隐藏值
    [DisplayName("书号")]
    [Required(ErrorMessage="书号是必须的")]
    [StringLength(160)] //长度最长为160
    [Required(ErrorMessage="Price is required")]
    [Range(0.01,100.00,ErrorMessage="价格必须在 0.01-- 100.00之间")]
     
  • 相关阅读:
    SSH-框架工作笔记
    Ajax基础
    Hibernate基础
    Struts1 中的国际化
    MyEclipse中的快捷键
    Oracle_存储过程
    oracle_开发子程序和包
    常用的正则表达式
    jQuery中的事件
    AcWing 1118. 分成互质组
  • 原文地址:https://www.cnblogs.com/guo0/p/3224418.html
Copyright © 2011-2022 走看看