----------------
--一个简单的密码非法字符校验,存在非法字符,就返回false;
CheckPassWord(‘hhhhhh哈哈’);//有中文,返回False
-------------------
function CheckPassWord(PassWord: string): boolean; //不允许(汉字和空格,双引号等)
var
wStr:WideString;
wChar:WideChar;
i:Integer;
vValue:Integer;
begin
Result:=False;
if PassWord=‘‘ then
Exit;
wStr:=PassWord;
for i:=1 to Length(wStr) do
begin
wChar:=wStr[i];
vValue:=Ord(wChar);
if vValue>126 then //127是个三角形算非法字符,汉字属于非法字符
Exit
else
begin
if vValue >32 then
begin
if vValue in [34,39,94,96] then// ("34),(‘39),(^94),(`96)
Exit;
end
else //0到32也认为是非字符 ; 32是空格
Exit;
end;
end;
Result:=True;
end;