vue中手机号,邮箱正则验证以及60s发送验证码
今天写了一个简单的验证,本来前面用的组件,但是感觉写的组件在此项目不是很好用,由于用到的地方比较少,所以直接写在了页面中。页面展示如图
- <div>
- <p class="fl">
- <input name="phone" type="number" placeholder="手机号" v-model="phone"/>
- <button type="button" :disabled="disabled" @click="sendcode" class="btns">{{btntxt}}</button>
- </p>
- <p class="fl" style="margin-left: 20px;">
- <input type="text" placeholder="验证码"/>
- </p>
- </div>
- <input type="button" value="查询" class="btns search" @click="query"/>
这里是script
里的内容
- export default {
- data: function () {
- return {
- disabled:false,
- time:0,
- btntxt:"获取验证码",
- formMess:{
- email:this.email,
- phone:this.phone
- }
- }
- },
- mounted: function () {
- },
- methods:{
- //验证手机号码部分
- sendcode(){
- var reg=11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
- //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
- if(this.phone==''){
- alert("请输入手机号码");
- }else if(!reg.test(this.phone)){
- alert("手机格式不正确");
- }else{
- this.time=60;
- this.disabled=true;
- this.timer();
- /*axios.post(url).then(
- res=>{
- this.phonedata=res.data;
- })*/
- }
- },
- timer() {
- if (this.time > 0) {
- this.time--;
- this.btntxt=this.time+"s后重新获取";
- setTimeout(this.timer, 1000);
- } else{
- this.time=0;
- this.btntxt="获取验证码";
- this.disabled=false;
- }
- },
- query(){
- var formMess=this.formMess
- Axios.post(api+"/order/select/reception", formMess)
- .then(function (res) {
- if(res.data.code==200){
- console.log(res.data.data);
- this.productResult=res.data.data;
- this.productResult.length=3;
- }else if(res.data.code==400){
- alert(res.data.message)
- }
- }.bind(this))
- },
- //邮箱验证
- sendEmail(){
- var regEmail= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
- if(this.email==''){
- alert("请输入邮箱");
- }else if(!regEmail.test(this.email)){
- alert("邮箱格式不正确");
- }
- }
- }
- }
vue中手机号,邮箱正则验证以及60s发送验证码的更多相关文章
- vue中的表单验证
http://www.cnblogs.com/luoxuemei/p/9295506.html /*是否合法IP地址*/ export function validateIP(rule, value, ...
- winform 学习之qq邮箱正则验证及常用正则
这段时间一直再做winform相关的项目,记录了一些东西 qq邮箱正则表达式: 第一种:字母和数字组合邮箱判断 string str = "justin1107@qq.com"; ...
- php email邮箱正则验证
国际域名格式如下: 域名由各国文字的特定字符集.英文字母.数字及“-”(即连字符或减号)任意组合而成, 但开头及结尾均不能含有“-”,“-”不能连续出现 . 域名中字母不分大小写.域名最长可达60个字 ...
- Vue中Form表单验证无法消除验证问题
iView的表单api给出了一个resetFields方法,用于重置整个表单输入的内容并清除验证提示. 但是有时候需要只消除部分的iview的resetFields方法源码是这样的resetField ...
- java邮箱正则验证
import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class tes ...
- 邮箱、手机号、中文 js跟php正则验证
邮箱正则: jS: var regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; //验证 if(regEmail.te ...
- ASP.NET中 RegularExpressValidator(正则验证)的使用
原文:ASP.NET中 RegularExpressValidator(正则验证)的使用 ylbtech-ASP.NET-Control-Validator: RegularExpressValida ...
- 在js中实现邮箱格式的验证
在js中实现邮箱格式的验证 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><htm ...
- JavaScript正则验证邮箱
正则表达式/^正则$/.test() <html> <head> <title>JavaScript</title> <meta charset= ...
随机推荐
- *AtCoder Grand Contest 002F - Leftmost Ball
$n \leq 2000,k \leq 2000$,现$n$种球每种有$k$个,在一种排列中,会把每种颜色的球第一个出现的涂成第0种(不同于原来的n种)颜色,问最终会出现多少种不同的序列.膜1e9+7 ...
- net3:Button的CommandName使用,AdRotator,BulletedList的使用
原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...
- Xcode打包应用为ipa
Xcode教程 Xcode4发布测试 打包Archive操作是本文要介绍的内容,发布测试的最后一步打包(Archive),Xcode4帮助文档有比较详细介绍,但是居然是错的,这里说明一下. 1.设置& ...
- 在 IntelliJ IDEA 中为自己设计的类库生成 JavaDoc
因为某个项目需要,为团队其他兄弟姐妹开发了一个 XML 分析处理器,并将其设计为一个类库,提供相应的 API 接口.为了方便大家的使用,需要生成对应的 JavaDoc 帮助文档,就像 JavaSE 标 ...
- Hdu5921 Binary Indexed Tree
Hdu5921 Binary Indexed Tree 思路 计数问题,题目重点在于二进制下1的次数的统计,很多题解用了数位DP来辅助计算,定义g(i)表示i的二进制中1的个数, $ans = \su ...
- Hadoop 连接mysql
1 mysql数据导入到hdfs数据 hadoop提供了org.apache.hadoop.io.Writable接口来实现简单的高效的可序列化的协议,该类基于DataInput和DataOutput ...
- [转] Python 常用第三方模块 及PIL介绍
原文地址 除了内建的模块外,Python还有大量的第三方模块. 基本上,所有的第三方模块都会在PyPI - the Python Package Index上注册,只要找到对应的模块名字,即可用pip ...
- centos安装python的虚拟环境和虚拟管理环境
一.大部分介绍的方式是使用pip安装:1.pip install virtualenv 2.pip install virtualenvwrapper 但是我安装完,并没有相应的命令:virt ...
- JavaScript 层
代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--& ...
- 基于MNIST数据的卷积神经网络CNN
基于tensorflow使用CNN识别MNIST 参数数量:第一个卷积层5x5x1x32=800个参数,第二个卷积层5x5x32x64=51200个参数,第三个全连接层7x7x64x1024=3211 ...