From af1752eb2b630d06ea2d2bf6276a428e988b5c95 Mon Sep 17 00:00:00 2001 From: zouying Date: Sat, 20 Oct 2012 22:39:49 +0800 Subject: [PATCH] Update 4.2.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 身份证获取的是貌似get函数中传入了mobile --- 4.2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/4.2.md b/4.2.md index 6c697fd0..8ac4a69c 100644 --- a/4.2.md +++ b/4.2.md @@ -146,12 +146,12 @@ Go里面提供了一个time的处理包,我们可以把用户的输入年月 如果我们想验证表单输入的是否是身份证,通过正则也可以方便的验证,但是身份证有15位和18位,我们两个都需要验证 //验证15位身份证,15位的是全部数字 - if m, _ := regexp.MatchString(`^(\d{15})$`, r.Form.Get("mobile")); !m { + if m, _ := regexp.MatchString(`^(\d{15})$`, r.Form.Get("usercard")); !m { return false } //验证18位身份证,18位前17位为数字,最后一位是校验位,可能为数字或字符X。 - if m, _ := regexp.MatchString(`^(\d{17})([0-9]|X)$`, r.Form.Get("mobile")); !m { + if m, _ := regexp.MatchString(`^(\d{17})([0-9]|X)$`, r.Form.Get("usercard")); !m { return false }