PDA

View Full Version : Verfication of a form field



alangnw
04-10-2009, 12:49 PM
Can anyone tell me how I can use this script sent to me (I'm assuming it's all there!) to verify an entry into an html form field? Thanks.


function Letra(Numero: Integer): string;
begin
Result:= copy('TRWAGMYFPDXBNJZSQVHLCKET',1 + numero mod 23,1);
end;

function EsNif(NIF: String): Boolean;
var
Numero: Integer;
begin
Result:= FALSE;
if TryStrToInt(Copy(NIF,1,Length(NIF)-1),Numero) then
Result:= Uppercase(Copy(NIF,Length(NIF),1)) = Letra(Numero);
end;

function EsNumero(Num: Char): Boolean;
begin
try
StrToInt(Num);
Result:=True;
Except
result:=False;
end;
end;

{Eliminamos espacios y separadores}
function CadLimpiaCar(NIF: String): String;
begin
Result:= NIF;
while (pos(' ',NIF)>0) do
delete(NIF,pos(' ',NIF),1);
while (pos('-',NIF)>0) do
delete(NIF,pos('-',NIF),1);
while (pos('/',NIF)>0) do
delete(NIF,pos('/',NIF),1);
Result:=NIF;
end;

Twey
04-10-2009, 01:17 PM
Um... what makes you think this is Javascript or at all applicable to HTML forms? It looks like some form of Pascal.

alangnw
04-10-2009, 01:33 PM
Ah - that answers my question then (I'd presumed because of how it was sent to me).... Thanks.