611
社区成员
发帖
与我相关
我的任务
分享
boolean f_is_telnum(string as) 可以这么写:
int li
li = pos(as, '-')
if li <> lastpos(as, '-') then return false //包含1个以上的- ,则有误
if li > 0 then as = left(as, li - 1) + mid(as, li + 1) //去换-
if not isnumber(as) then return false //包含数字以外的字符,则有误
if len(as) > 12 then return false //长度过长,则有误
choose case left(as, 1)
case '1' //手机
case '0' //固化
case else
return false //错误
end choose
return true在dw的itemchanged事件中写:
if isnull(dwo) or row < 1 then return
if dwo.name = '不能为空的字段的字段名' then
if data = '' then
messagebox('提示', '字段不能为空!')
return
end if
elseif dwo.name = '电话字段' then
//电话号码只能包括数字和-,固话以0开始,手机以1开始
if not f_is_telnum(data) then
messagebox('提示', '电话号码格式不正确')
end if
end if