电话邮件手机验证的正则表达式
178 list = new ListItem();
179 list.Text = "电话";
180 list.Value = "0";
181 validType.Items.Add(list);
182
183 list = new ListItem();
184 list.Text = "邮件";
185 list.Value = "1";
186 validType.Items.Add(list);
187
188 list = new ListItem();
189 list.Text = "手机";
190 list.Value = "2";
191 validType.Items.Add(list);
192
193 validTextBox = new TextBox();
194 validTextBox.ID = "validTextBox";
195
196 //phone valid
197 phoneValidator = new RequiredFieldValidator();
198 phoneValidator.ID = "phoneValidator";
199 phoneValidator.ControlToValidate = validTextBox.ID;
200 phoneValidator.Text = "电话号码不能为空!";
201 phoneValidator.Display = ValidatorDisplay.Dynamic;
202
203 phoneFormatValidator = new RegularExpressionValidator();
204 phoneFormatValidator.ID = "phoneFormatValidation";
205 phoneFormatValidator.Text = "电话号码格式不正确";
206 phoneFormatValidator.Display = ValidatorDisplay.Dynamic;
207 phoneFormatValidator.ControlToValidate = validTextBox.ID;
208 phoneFormatValidator.ValidationExpression = @"(0\d{2}-\d{8}|0\d{3}-\d{7})-\d{2,4}|(0\d{2}-\d{8}|0\d{3}-\d{7})";
209
210 //email valid
211 emailValidator = new RequiredFieldValidator();
212 emailValidator.ID = "emailValidator";
213 emailValidator.ControlToValidate =
214 validTextBox.ID;
215 emailValidator.Text = "请输入邮件地址!";
216 emailValidator.Display = ValidatorDisplay.Dynamic;
217
218 emilFormatValidator = new RegularExpressionValidator();
219 emilFormatValidator.ID = "emailFormatValidation";
220 emilFormatValidator.Text = "邮件格式不正确";
221 emilFormatValidator.Display = ValidatorDisplay.Dynamic;
222 emilFormatValidator.ControlToValidate = validTextBox.ID;
223 emilFormatValidator.ValidationExpression=@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
224
225 //handphone valid
226 handphoneValidator = new RequiredFieldValidator();
227 handphoneValidator.ID = "handphoneValidator";
228 handphoneValidator.ControlToValidate =
229 validTextBox.ID;
230 handphoneValidator.Text = "请输入手机号码!";
231 handphoneValidator.Display = ValidatorDisplay.Dynamic;
232
233 handphoneFormatValidator = new RegularExpressionValidator();
234 handphoneFormatValidator.ID = "handphoneValidation";
235 handphoneFormatValidator.Text = "手机号码格式不正确";
236 handphoneFormatValidator.Display = ValidatorDisplay.Dynamic;
237 handphoneFormatValidator.ControlToValidate = validTextBox.ID;
238 handphoneFormatValidator.ValidationExpression = @"^1[3,5][0-9][0-9]{8}$";
179 list.Text = "电话";
180 list.Value = "0";
181 validType.Items.Add(list);
182
183 list = new ListItem();
184 list.Text = "邮件";
185 list.Value = "1";
186 validType.Items.Add(list);
187
188 list = new ListItem();
189 list.Text = "手机";
190 list.Value = "2";
191 validType.Items.Add(list);
192
193 validTextBox = new TextBox();
194 validTextBox.ID = "validTextBox";
195
196 //phone valid
197 phoneValidator = new RequiredFieldValidator();
198 phoneValidator.ID = "phoneValidator";
199 phoneValidator.ControlToValidate = validTextBox.ID;
200 phoneValidator.Text = "电话号码不能为空!";
201 phoneValidator.Display = ValidatorDisplay.Dynamic;
202
203 phoneFormatValidator = new RegularExpressionValidator();
204 phoneFormatValidator.ID = "phoneFormatValidation";
205 phoneFormatValidator.Text = "电话号码格式不正确";
206 phoneFormatValidator.Display = ValidatorDisplay.Dynamic;
207 phoneFormatValidator.ControlToValidate = validTextBox.ID;
208 phoneFormatValidator.ValidationExpression = @"(0\d{2}-\d{8}|0\d{3}-\d{7})-\d{2,4}|(0\d{2}-\d{8}|0\d{3}-\d{7})";
209
210 //email valid
211 emailValidator = new RequiredFieldValidator();
212 emailValidator.ID = "emailValidator";
213 emailValidator.ControlToValidate =
214 validTextBox.ID;
215 emailValidator.Text = "请输入邮件地址!";
216 emailValidator.Display = ValidatorDisplay.Dynamic;
217
218 emilFormatValidator = new RegularExpressionValidator();
219 emilFormatValidator.ID = "emailFormatValidation";
220 emilFormatValidator.Text = "邮件格式不正确";
221 emilFormatValidator.Display = ValidatorDisplay.Dynamic;
222 emilFormatValidator.ControlToValidate = validTextBox.ID;
223 emilFormatValidator.ValidationExpression=@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
224
225 //handphone valid
226 handphoneValidator = new RequiredFieldValidator();
227 handphoneValidator.ID = "handphoneValidator";
228 handphoneValidator.ControlToValidate =
229 validTextBox.ID;
230 handphoneValidator.Text = "请输入手机号码!";
231 handphoneValidator.Display = ValidatorDisplay.Dynamic;
232
233 handphoneFormatValidator = new RegularExpressionValidator();
234 handphoneFormatValidator.ID = "handphoneValidation";
235 handphoneFormatValidator.Text = "手机号码格式不正确";
236 handphoneFormatValidator.Display = ValidatorDisplay.Dynamic;
237 handphoneFormatValidator.ControlToValidate = validTextBox.ID;
238 handphoneFormatValidator.ValidationExpression = @"^1[3,5][0-9][0-9]{8}$";