@touchstart="touchStart($event)"
@touchend="touchEnd($event)"
@touchmove="touchMove($event)"
const datas = reactive({
startX: 0,
moveMar: 0,
})
function touchStart(e) {
//手指滑动开始的位置
datas.startX = e.targetTouches[0].pageX
}
function touchMove(e) {
//手指滑动的距离位置减去手指开始的位置得到滑动多少距离
datas.moveMar = e.targetTouches[0].pageX - datas.startX
}
function touchEnd(e) {
//如果滑动的距离大于0就是右滑动,小于0就是左滑动
if (datas.moveMar < 0) {
console.log('left')
} else if (datas.moveMar >0 ) {
console.log('rigth')
}
datas.moveMar = 0
}
//判断是左点击 还是右点击
//点击元素距离父盒子的左距离
//如果当前元素的左边距小于父盒子的总宽度的一半就是点击的左边否则就是右边
'1234567890'.replace(/[^0-9]/g, '')
.replace(/(.{5})/g, '$1 ')
.replace(/\s*$/g, '')
1.校验开头不能有空格:
jQuery.validator.addMethod("firstNotHasBlank", function(value, element) {
var fBlank =/^\S+/;
return this.optional(element) || (fBlank.test(value));
}, "开头不能有空格");
2.校验结尾不能有空格:
jQuery.validator.addMethod("lastNotHasBlank", function(value, element) {
var lBlank =/\S+$/;
return this.optional(element) || (lBlank.test(value));
}, "结尾不能有空格");
3.校验不能包含空格:
jQuery.validator.addMethod("notHasBlank", function(value, element) {
var pwdblank = /^\S*$/;
return this.optional(element) ||(pwdblank.test(value));
}, "不可包含空格");
vue3判断滚动是左滑还是右滑,和输入5位号码加一个占位符,js校验不能输入空格
于 2023-02-11 10:57:09 首次发布