判断是否为空是否有敏感词,是否有匹配项

来源:互联网 发布:广州sql培训班 编辑:程序博客网 时间:2024/04/27 23:34
//点击保存按钮                $scope.save = function(){                    var i = $scope.datas.length;+1                    $scope.tips = false;//控制错误信息是否显示                    $scope.cw = [];//放错误信息的数组                    if($scope.name == undefined ||$scope.name == null){                        $scope.cw.push("姓名不能为空");                        alert("姓名不能为空");                        return;                    }                    if(!/^\d+$/.test($scope.age)){                        $scope.cw.push("年龄格式错误");                        alert("年龄格式错误");                        return;                    }                    if($scope.cw.length>0){                        $scope.tips = true;                    }else{                        var data2 = {                            id:i++,                            name:$scope.name,                            age:$scope.age,                            pinyin:$scope.pinyin,                            job:$scope.job,                            system:"删除"                        };                        $scope.datas.push(data2);//把数组放入原始数组中                        $scope.isShow = false;//让添加页不显示                    }

//查询按钮                $scope.sel = function(){                    if($scope.selName == null){//如果为空提示                        alert("不能为空");                    }else{                        if($scope.selName.match("王")){                            alert("有敏感词汇");                        }else{                            var filter = $filter("filter");                            var shu = filter($scope.datas,{name:$scope.selName});                            if(shu.length == 0){                                alert("未找到内容");                            }else{                                $scope.datas = shu;                            }                        }                    }                }
原创粉丝点击