资讯专栏INFORMATION COLUMN

Magento中的表单在客户端的验证方法

邱勇 / 2399人阅读

摘要:功能介绍有表单的地方就一定少不了表单验证,对而表单验证一般为了安全,都会有客户端表单验证和服务器端验证,这里,记录下在客户端的有关验证模板文件中,添加类属性值客户端表单验证一般都是通过来验证的,只需要使用类名来添加属性即可

功能介绍:有表单的地方就一定少不了表单验证,对而表单验证一般为了安全,都会有客户端表单验证和服务器端验证,这里,记录下magento在客户端的有关验证:
模板文件中,添加class类属性值:

//客户端表单验证一般都是通过js来验证的,只需要使用class类名来添加属性即可
validate-select
//Please select an option
required-entry
//This is a required field
validate-digits
//Please use numbers only in this field. please avoid spaces or other characters such as dots or commas
validate-alpha
//Please use letters only (a-z or A-Z) in this field.
validate-number
//Please enter a valid number in this field
validate-code
//Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.
validate-alphanum
//Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed
validate-street
//Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field
validate-phoneStrict
//Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890
validate-phoneLax
//Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890
validate-fax
//Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890
validate-date
//Please enter a valid date
validate-email
//Please enter a valid email address. For example johndoe@domain.com.
validate-emailSender
//Please use only letters (a-z or A-Z), numbers (0-9) , underscore(_) or spaces in this field.
validate-password
//Please enter 6 or more characters. Leading or trailing spaces will be ignored
validate-admin-password
//Please enter 7 or more characters. Password should contain both numeric and 
alphabetic characters
validate-cpassword
//Please make sure your passwords match
validate-url
//Please enter a valid URL. http:// is required
validate-clean-url
//Please enter a valid URL. For example http://www.example.com or www.example.com
validate-identifier
//Please enter a valid Identifier. For example example-page, example-page.html or anotherlevel/example-page
validate-xml-identifier
//Please enter a valid XML-identifier. For example something_1, block5, id-4
validate-ssn
//Please enter a valid social security number. For example 123-45-6789
validate-zip
//Please enter a valid zip code. For example 90602 or 90602-1234
validate-zip-international
//Please enter a valid zip code
validate-date-au
//Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006
validate-currency-dollar
//Please enter a valid $ amount. For example $100.00
validate-one-required
//Please select one of the above options.
validate-one-required-by-name
//Please select one of the options.
validate-not-negative-number
//Please enter a valid number in this field
validate-state
//Please select State/Province
validate-new-password
//Please enter 6 or more characters. Leading or trailing spaces will be ignored
validate-greater-than-zero
//Please enter a number greater than 0 in this field
validate-zero-or-greater
//Please enter a number 0 or greater in this field
validate-cc-number
//Please enter a valid credit card number.
validate-cc-type
//Credit card number doesn’t match credit card type
validate-cc-type-select
//Card type doesn’t match credit card number
validate-cc-exp
//Incorrect credit card expiration date
validate-cc-cvn
//Please enter a valid credit card verification number.
validate-data
//Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field,first character should be a letter.
validate-css-length
//Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%
validate-length
//Maximum length exceeded

在模板文件底部添加:

备注:服务端验证,可以使用php,也可以使用magento中采用ajax验证。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/21412.html

相关文章

  • Magento中的常用方法总结

    摘要:记录下中的常用方法,一起来学习。例如在模板页面,表单提交,需要页面跳转模块控制器方法在控制器获取表单提交数据将接收到的数据存入到数据库从当前控制器实现跨控制器的跳转在模板页面加载或者图片返回当前页面的路径显示登录路径 记录下Magento中的常用方法,一起来学习Magento。 //1.例如在模板页面,表单提交,需要页面跳转: //2.在控制器获取表单提交数据: $data = $t...

    ddongjian0000 评论0 收藏0
  • 四种表单验证方法的分析和比较

    摘要:本文将列举四种不同原理的表单验证方法,并给出各方法在服务器上的实现。小结上述四种验证方法各有优缺点,用户应该根据需求选择不同的方法。 前言 任何可以交互的站点都有输入表单,只要有可能,就应该对用户输入的数据进行验证。无论服务器后端是什么样的系统,都不愿意把时间浪费在一些无效的信息上,必须对表单数据进行校验,若有不符合规定的表单输入,应及时返回并给出相应的提示信息。本文将列举四种不同原理...

    starsfun 评论0 收藏0
  • 四种表单验证方法的分析和比较

    摘要:本文将列举四种不同原理的表单验证方法,并给出各方法在服务器上的实现。小结上述四种验证方法各有优缺点,用户应该根据需求选择不同的方法。 前言 任何可以交互的站点都有输入表单,只要有可能,就应该对用户输入的数据进行验证。无论服务器后端是什么样的系统,都不愿意把时间浪费在一些无效的信息上,必须对表单数据进行校验,若有不符合规定的表单输入,应及时返回并给出相应的提示信息。本文将列举四种不同原理...

    wwolf 评论0 收藏0
  • Magento后台表单元素标签(2)--显示日期

    摘要:添加可以先在外写好样式,再添加定义按钮的。也可以直接写,例如。类型,可以为是否为必选项定义按钮的添加图片代码。 功能介绍:今天要做一个后台表单元素显示出日期时间,开始以为跟Magento后台用到的表单元素标签(1)的功能一样,只需要设置type类型设置为date就可,但是设置了,开始怎么也弄不出来,又想着在后台加载一些js包,引用外部的js插件来实现这个功能,后来请教公司技术牛人,说可...

    diabloneo 评论0 收藏0
  • Magento的三种默认提示信息

    摘要:发送失败后的提示信息同样在控制器中使用备注,这个提示信息是红色的。需要注意的是,使用上面三种提示信息,需要在中添加如下代码需要添加如下代码在模板页面添加 如何使用Magento中的默认的提示信息? 比如,表单提交的时候,提交成功or提交失败,都应有一个反馈信息,来告诉用户,提交操作是否成功,在magento中,有几种默认的提示: 发送成功后的提示信息: //在控制器中使用: Mage:...

    Java3y 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<