If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > covert java script to vb script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-06, 21:04
irisclaire irisclaire is offline
Registered User
 
Join Date: Jan 2006
Posts: 10
covert java script to vb script

Hello everyone I am having trouble converting this codes.I want to convert this codes to vbscript: to validate if the user enter text on each field.

<script Language="JavaScript">
function FrontPage_Form1_Validator(theForm)
{
if (theForm.company_name.value == "")
{
alert("Please enter a value for the \"Company_name\" field.");
theForm.company_name.focus();
return (false);
}
if (theForm.company_add.value == "")
{
alert("Please enter a value for the \"company_add\" field.");
theForm.company_add.focus();
return (false);
}
if (theForm.con_per.value == "")
{
alert("Please enter a value for the \"Con_per\" field.");
theForm.con_per.focus();
return (false);
}
if (theForm.con_no.value == "")
{
alert("Please enter a value for the \"con_no\" field.");
theForm.con_no.focus();
return (false);
}
return (true);
}

Any help much appreciated

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-09-06, 23:23
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
With server-side validation you'll have to have a system to get back to the same or different page with messages.

And here are some interesting server-side validation links:

Server-Side Form Validation by Dianna Leech - 12/1/1999
http://www.4guysfromrolla.com/webtech/120199-1.shtml

An Email Validation Routine by Joćo Vieira - 4/11/1999
http://www.4guysfromrolla.com/webtech/041199-1.shtml
Somewhat shorter.

An Email Validation Script by Ben Durbin - 5/19/1999
http://www.4guysfromrolla.com/webtech/051999-1.shtml
Longer.
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #3 (permalink)  
Old 01-10-06, 10:52
irisclaire irisclaire is offline
Registered User
 
Join Date: Jan 2006
Posts: 10
thanks... really helps...
Reply With Quote
  #4 (permalink)  
Old 01-16-06, 04:55
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
he didnt say anything about server side validation.... and i would not suggest using it either. it adds extra processes, overhead, delay and bandwitdth usage...

Iris
while you may want to convert all of that to VB Script (which i love VB Script)
vb Script only works in Internet Explorer. it does not work with Firefox and i dont think it wirks with netscape or opera browsers either.

so only the peiople using IE would be able to use your site.

i just spent 2 weekends and about 60 hours converting an entire website from VBScript to JavaScript all because the site would not work with any other browser.

if you need help understanding how the Javascript works, i can help you. its almost identical to VBScript as far as logic is concerned.
__________________
.
.
http://www.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
  #5 (permalink)  
Old 01-17-06, 07:13
irisclaire irisclaire is offline
Registered User
 
Join Date: Jan 2006
Posts: 10
... hello!!
i want to covert it in vbscript inpite the fact that it only works in IE, i want still to covert it 'coz it is one of the requirement i need to meet but don't know how to code/do it in VBSCRIPT.
can you help me??
Reply With Quote
  #6 (permalink)  
Old 01-29-06, 02:15
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
here you go.
includes some minor structural chages. i like it this way better.. it tells you all at once what is wrong with the form, instead of a pop up for each blank field seperately.
then if there is no problems, it submits the form

Code:
<html>
<body>
<form name="CompanyData" action="testForm.htm" method="post">

Company Name <input type="text" name="company_name"> <br>
Company Address <input type="text" name="company_add"> <br>
Contact Person <input type="text" name="con_per"> <br>
Contact Number <input type="text" name="con_no"> <br>
<br>
<input type="button" value="Submit" onClick="FrontPage_Form1_Validator('CompanyData')">

</form>
</body>
</html>

<script Language="VBScript">

sub FrontPage_Form1_Validator(theForm)

	Set theForm = Document.forms(theForm)

	strMessage=""

	if theForm.company_name.value = "" then
		strMessage ="Company Name" & vbCr
		theForm.company_name.focus()
	end if

	if theForm.company_add.value = "" then 
		strMessage = strMessage & "Company Address" & vbCr
		theForm.company_add.focus()
	end if

	if theForm.con_per.value = "" then
		strMessage = strMessage & "Contact Person" & vbCr
		theForm.con_per.focus()
	end if

	if theForm.con_no.value = "" then 
		strMessage = strMessage & "Contact Number" & vbCr
		theForm.con_no.focus()
	end if

	' ---------------------------------------------------

	if len(strMessage)>0 then
		' if a strMessage exists then there was a problem, display it.
		strMessage = "Please Enter Values for the Following Fields :" & vbCr & vbCr & strMessage 
		alert strMessage 
	else
		' If the strMessage is empty, there was no problems, submit the form
		theForm.submit()
	end if

end sub

</script>
__________________
.
.
http://www.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On