Click to See Complete Forum and Search --> : form validation
Dr_Michael
January 25th, 2005, 04:09 AM
I need to validate a form before submitting but I get the error:
Object doesn't support this property or method: 'frmTPOnline.submit'
:sick:
<!-- Data Validation-->
<SCRIPT LANGUAGE = "VBScript">
Sub Submit_OnClick()
if frmTPOnline.txtquantity.value = "" then
MsgBox "empty!"
else
msgbox "OK!"
frmTPOnline.submit()
end if
End Sub
</SCRIPT>
<body>
<FORM NAME = "frmTPOnline" ACTION="TPOnline.ASP" METHOD = "POST">
...
visualAd
January 25th, 2005, 05:22 AM
:eek: :eek:
Why are you using VBScript?? - This only works in Internet Explorer. Javascript is what you need as it is cross browser.
<!-- Data Validation-->
<SCRIPT type="text/javascript>>
<!--
function validate()
{
if (frmTPOnline.txtquantity.value == "")
{
alert('Empty');
return false;
}
else
{
alert('OK');
return true;
}
}
//-->
</SCRIPT>
<body>
<FORM NAME="frmTPOnline" ACTION="TPOnline.ASP" METHOD = "POST" onsubmit="return validate();">
...
Dr_Michael
January 26th, 2005, 02:41 AM
Thank you for the code but in the intranet we use mostly VBscript.
I found the cause of the problem in my code: The form.submit couldnt be invoked because there was another object (button) with the name "submit" so there was conflict. I renamed the button to "cmdSubmit" and everything went fine since then.
visualAd
January 27th, 2005, 07:05 AM
Thank you for the code but in the intranet we use mostly VBscript.
I found the cause of the problem in my code: The form.submit couldnt be invoked because there was another object (button) with the name "submit" so there was conflict. I renamed the button to "cmdSubmit" and everything went fine since then.
I Guess that is understandable but it does lock people down to Internet Explorer. Does VBScript offer advanced functionality over Javascript?
Dr. Script
January 27th, 2005, 06:39 PM
Indeed as mentioned JS would be the better source (and further checked on the server); however, either way, get your script tag correct:<script type="text/vbscript"> Dr. Script
Cimperiali
January 28th, 2005, 10:48 AM
Nothing of bad, in any case, to have javascript even where most
is done in VbScript. However if a pre requisite of the company is to
use Iexplorer, you can use VbScript instead, even if it does not add
to the power of javascript, and even if javascript would be perfectly
fine with IExp....
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.