B
benqq
Unregistered / Unconfirmed
GUEST, unregistred user!
HTNL如下:
<html>
<head>
<title>表单输入演示页</title>
<meta http-equiv="目录类型" content="文本/html; 字符集=gb2312">
<script language="javaScript">
<!--
function checkempty(text){
return (text.length>0);
}
function validateform(){
validate=true;
if (!checkempty(document.PAGE1.USERID.value))
{validate=false;alert("请填入您的用户名,谢谢!");
return validate;
}
if (!checkempty(document.PAGE1.PASSWORD.value))
{validate=false;alert("请填入您的密码,谢谢!");
return validate;
}
}
//--></script>
</head>
<body >
<form name="PAGE1" action="http://www.dsfhjk.com/index.asp" method="post" onSubmit="return validateform()" >
<p> userid:
<input type="text" name="USERID" value=">
password:
<input type="password" name="PASSWORD">
</p>
<p>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Reset" value="清除">
</p>
</form>
</div>
</body>
</html>
-------------------------------------------------------------------
procedure TForm1.WebBrowserEx1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
doc:IHTMLDocument2;
all:IHTMLElementCollection;
len,i,lp:integer;
j:OleVariant;
spDisp : IDispatch;
HtmlForm: IHTMLFormELement;
begin
if URL='' then
exit;
if UpperCase(URL) = UPPERCASE(OpenDlg1.FileName) then
begin
doc :=WebBrowserEx1.Document as IHTMLDocument2;
all:=doc.all;
len:=all.Length;
for i := 0 to len-1 do
begin
spDisp:=all.item(i,1);
if SUCCEEDED(spDisp.QueryInterface(IHTMLFormElement ,HtmlForm)) then
begin
memo1.Lines.add('表单的Action属性:'+HtmlForm.action);
HtmlForm.submit; //自动提交,但不会执行javaScript的判断???
end;
end;
end;
end;
------------------------------------------------------------------------
执行时不管文本框是否为空,它就提交了,我需要它执行那个javascript函数。点击submit
键就正常。
<html>
<head>
<title>表单输入演示页</title>
<meta http-equiv="目录类型" content="文本/html; 字符集=gb2312">
<script language="javaScript">
<!--
function checkempty(text){
return (text.length>0);
}
function validateform(){
validate=true;
if (!checkempty(document.PAGE1.USERID.value))
{validate=false;alert("请填入您的用户名,谢谢!");
return validate;
}
if (!checkempty(document.PAGE1.PASSWORD.value))
{validate=false;alert("请填入您的密码,谢谢!");
return validate;
}
}
//--></script>
</head>
<body >
<form name="PAGE1" action="http://www.dsfhjk.com/index.asp" method="post" onSubmit="return validateform()" >
<p> userid:
<input type="text" name="USERID" value=">
password:
<input type="password" name="PASSWORD">
</p>
<p>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Reset" value="清除">
</p>
</form>
</div>
</body>
</html>
-------------------------------------------------------------------
procedure TForm1.WebBrowserEx1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
doc:IHTMLDocument2;
all:IHTMLElementCollection;
len,i,lp:integer;
j:OleVariant;
spDisp : IDispatch;
HtmlForm: IHTMLFormELement;
begin
if URL='' then
exit;
if UpperCase(URL) = UPPERCASE(OpenDlg1.FileName) then
begin
doc :=WebBrowserEx1.Document as IHTMLDocument2;
all:=doc.all;
len:=all.Length;
for i := 0 to len-1 do
begin
spDisp:=all.item(i,1);
if SUCCEEDED(spDisp.QueryInterface(IHTMLFormElement ,HtmlForm)) then
begin
memo1.Lines.add('表单的Action属性:'+HtmlForm.action);
HtmlForm.submit; //自动提交,但不会执行javaScript的判断???
end;
end;
end;
end;
------------------------------------------------------------------------
执行时不管文本框是否为空,它就提交了,我需要它执行那个javascript函数。点击submit
键就正常。