一个用angularjs写的邮编校验

来源:互联网 发布:python的try except 编辑:程序博客网 时间:2024/04/26 23:34

$scope.saveAddress=function(){

if ($scope.address.code.length!=6) {

$ionicLoading.show({
template : "请输入正确的邮编!",
noBackdrop : true,
duration : 500
});
return false;
}else{
var pattern =/^[0-9]{6}$/;
if(!pattern.exec($scope.address.code)){
$ionicLoading.show({
template : "请输入正确的邮政编码!",
noBackdrop : true,
duration : 500
});
return false;
}

}

$http({
method : 'post',
url : global.httpurl+'/address/addAddress',
data:"&trueName="+$scope.address.name+"&mobPhone="+$scope.address.telephone+"&areaInfo="+$scope.address.areaInfo+"&address="+$scope.address.address+"&zipCode="+$scope.address.code+"&provinceId="+localStorage.pcode+"&cityId="+localStorage.ccode+"&areaId="+localStorage.acode+"&isDefault="+localStorage.isDefault,
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8;' }
})
.success(function(response) {
if(response.code == 0){
window.location.href="#/address"
}else{
alert(response.m);
}


})
.error(function(response) {
$ionicPopup.alert({
title: '请求结果',
template: 'save操作失败!'
});
});
}

0 0