Authored by yyq

字符长度校验

... ... @@ -9,7 +9,7 @@ var $ = require('yoho-jquery'),
area = require('./areaSelect'),
dialog = require('../../common/dialog');
var stringHandle = require('../../common/helpers/stringHandle');
var stringHandle = require('../../common/stringHandle');
var Dialog = dialog.Dialog,
Confirm = dialog.Confirm,
... ... @@ -105,7 +105,7 @@ function syncShowMoreBtn() {
// 地址校验,支持单个字段与多字段
function validateAddress(data) {
var regx = {
consignee: /^([\u4e00-\u9fa5\w]{1,20})$/,
consignee: /^([\u4e00-\u9fa5\w*]{1,20})$/,
areaCode: /^[0-9]{6,9}$/,
mobile: /^\d{3}(\d{4}|\*{4})\d{1,8}$/,
phone: /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/
... ... @@ -120,6 +120,9 @@ function validateAddress(data) {
!regx[i].test(data[i])) {
pass = false;
}
if (i === 'consignee' && stringHandle.chinese2(data[i]) > 20) {
pass = false;
}
}
return pass;
}
... ... @@ -136,7 +139,7 @@ function bindOperateEvent($el) {
if (!val) {
tip = '收货人不能为空';
} else if (stringHandle.chinese2(val) > 20) {
tip = '收货人姓名最多支持20个字';
tip = '收货人姓名最多支持20个字';
} else if (!validateAddress({consignee: val})) {
tip = '收货人姓名不支持特殊符号';
}
... ...
... ... @@ -9,7 +9,7 @@ var regionCode = require('./common-address');
var dialog = require('../common/dialog');
var stringHandle = require('../common/helpers/stringHandle');
var stringHandle = require('../common/stringHandle');
var Alert = dialog.Alert;
... ... @@ -180,10 +180,10 @@ function blurAction(opt) {
value = opt.val;
if (opt.inputName === 'addressName') {
regular = /^([\u4e00-\u9fa5\w]{1,20})$/;
regular = /^([\u4e00-\u9fa5\w*]{1,20})$/;
if (stringHandle.chinese2(value) > 20 || stringHandle.chinese2(value) < 1) {
msg = '收货人姓名最多支持20个字';
msg = '收货人姓名最多支持20个字';
res = false;
domClass = 'form-info form-error';
} else if (regular.test(opt.val) === false) {
... ...
... ... @@ -9,7 +9,7 @@ var ordersApi = require('./orders-api');
var dialog = require('../../common/dialog');
var stringHandle = require('../../common/helpers/stringHandle');
var stringHandle = require('../../common/stringHandle');
var Dialog = dialog.Dialog;
var Confirm = dialog.Confirm;
... ... @@ -310,7 +310,7 @@ function validateForm() {
$errPhone = $phone.siblings('.error'),
$errTel = $tel.siblings('.error');
var nameReg = /^([\u4e00-\u9fa5\w]{1,20})$/;
var nameReg = /^([\u4e00-\u9fa5\w*]{1,20})$/;
var addressReg = /^[a-zA-Z0-9-#()()\u4e00-\u9fa5]+$/;
var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
var telCodeReg = /^[0-9]{3,4}$/;
... ... @@ -322,7 +322,7 @@ function validateForm() {
name: function(name) {
if (stringHandle.chinese2(name) > 20) {
$errName.html(_errorHtml);
$errName.find('b').html('收货人姓名最多支持20个字');
$errName.find('b').html('收货人姓名最多支持20个字');
$errName.show();
return false;
} else if (!nameReg.test(name)) {
... ...
... ... @@ -7,7 +7,7 @@ var $ = require('yoho-jquery'),
Addr = require('./common-address'),
_dialog = require('../common/dialog');
var stringHandle = require('../common/helpers/stringHandle');
var stringHandle = require('../common/stringHandle');
var $goodsTable = $('#goods-table'),
$checkBox = $goodsTable.find('input[type="checkbox"]'),
... ... @@ -476,7 +476,7 @@ function packRefundInfo(returnMode) {
// 打包换货信息
function packExchangeInfo() {
var nameReg = /^([\u4e00-\u9fa5\w]{1,20})$/;
var nameReg = /^([\u4e00-\u9fa5\w*]{1,20})$/;
var res = {};
res.goods = packGoogsList();
... ... @@ -486,7 +486,7 @@ function packExchangeInfo() {
if (!res.consigneeName) {
verifyTip = '请填写收货人姓名';
} else if (stringHandle.chinese2(res.consigneeName) > 20) {
verifyTip = '收货人姓名最多支持20个字';
verifyTip = '收货人姓名最多支持20个字';
} else if (!nameReg.test(res.consigneeName)) {
verifyTip = '收货人姓名不支持特殊符号';
}
... ...