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= ...
随机推荐
- 解决centos7中ens33中不显示IP等问题
在虚拟机中安装centos7,输入ifconfig显示command not found.在sbin目录中发现没有ifconfig文件,这是因为centos7已经不使用 ifconfig命令了,已经用 ...
- 【SPOJ220】Relevant Phrases of Annihilation(后缀数组,二分)
题意: n<=10,len<=1e4 思路: #include<cstdio> #include<cstring> #include<string> # ...
- *AtCoder Regular Contest 096E - Everything on It
$n \leq 3000$个酱,丢进拉面里,需要没两碗面的酱一样,并且每个酱至少出现两次,面的数量随意.问方案数.对一给定质数取模. 没法dp就大力容斥辣.. $Ans=\sum_{i=0}^n (- ...
- BestCoder Round #25 1002 Harry And Magic Box [dp]
传送门 Harry And Magic Box Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- bash变量类型详解
本地变量:作用于当前shell,对当前shell之外的其他shell进程和当前shell子进程均无效. 本地变量赋值为 name='value' value可以是字符串或者是变量,引用变量使用${na ...
- Redis数据结构之跳跃表
跳跃表是一种有序数据结构,它通过在每个节点中维持多个指向其他节点的指针,从而达到快速访问节点的目的. 一.跳跃表结构定义1. 跳跃表节点结构定义: 2. 跳跃表结构定义: 示例: 二.跳跃表节点中各种 ...
- BZOJ——1720: [Usaco2006 Jan]Corral the Cows 奶牛围栏
http://www.lydsy.com/JudgeOnline/problem.php?id=1720 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1 ...
- TreeView 与 ListView
ListView: viewStyle icon 大图标 list 列表,单列 report 报表 smallIcon 小图标 largeImage 与icon对应 smallImage 与saml ...
- 使用nginx转发不了静态文件
从django runserver的请求来看,都收不到静态文件请求, 查看firefox的web console请求,发现都是403 然后发现nginx不在当前用户组,并且当前用户的项目的读写权限是7 ...
- C#如何设置控件水平对齐,垂直对齐
如果要设置一些控件垂直对齐,点击这个按钮 如果要设置水平对齐,则点击这个按钮,选中控件之后点击左对齐(多个按钮都试下吧,总归能对齐到你要的效果的)