电话号码的HTML验证 [英] HTML Validation for phone numbers

查看:88
本文介绍了电话号码的HTML验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是HTML的新手,任何人都可以帮我验证一个只有'+'的电话号码,数字值和电话号码不超过13个号码,并用'@'和''验证电子邮件。 ',我不想使用javascript

I am new to HTML,can any one please help me to validate a phone number only with '+' and numeric values and phone number shud not exceed 13 numbers,and to validate email with a '@' and a '.',I dont want to use javascript

推荐答案

在HTML5中你可以使用< input type =' tel'> < input type ='email'>

In HTML5 you can use <input type='tel'> and <input type='email'>

您还可以指定特定模式,例如< input type ='tel'pattern ='[\ +] \\\ {2} [\(] \d {2} [\ )] \d {4} [\-] \d {4}'title ='电话号码(格式:+99(99)9999-9999)'>

You can also specify a specific pattern like <input type='tel' pattern='[\+]\d{2}[\(]\d{2}[\)]\d{4}[\-]\d{4}' title='Phone Number (Format: +99(99)9999-9999)'>

类似 pattern ='^ \ +?\d {0,13}'会给你一个可选的+最多13位数

Something like pattern='^\+?\d{0,13}' Would give you an optional + and up to 13 digits

这篇关于电话号码的HTML验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆