Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help to change VBScript into JavaScript

Status
Not open for further replies.

1793

Programmer
May 16, 2001
3
CA
I have a function written in VBScript that I need now in JavaScript. But I don't know JavaScript and I need it urgent so no time to study. If somebody can help me and just write it for me in JavaScript it would be great.

<script LANGUAGE=&quot;VBScript&quot;>


Function IsMyFormValid
if CC.date1.value <> Empty then
IsMyFormValid=true
else
IsMyFormValid= false
alert &quot;You didn't enter a date.&quot;
exit function
end if
if CC.Hours.value <> Empty then
IsMyFormValid=true
else
IsMyFormValid= false
alert &quot;You didn't enter the hours.&quot;
exit function
end if

if CC.Minutes.value <> Empty then
IsMyFormValid=true
else
IsMyFormValid= false
alert &quot;You didn't enter the minutes.&quot;
exit function
end if

if CC.Hours.value<24 then
IsMyFormValid=true
else
IsMyFormValid= false
alert &quot;The hours that you have entered are incorrect.&quot;
exit function
end if

if CC.Minutes.value<60 then
IsMyFormValid=true
else
IsMyFormValid= false
alert &quot; The minutes that you have entered are incorrect.&quot;
exit function
end if
vDate=Date()
vDate1=Date() + 7
vUserDate=Cdate(CC.date1.value)
if vUserDate < vDate then
IsMyFormValid= false
alert &quot;You must enter a date between: &quot; & vDate & &quot; and &quot; & vDate1 & &quot; .&quot;
exit function
else
IsMyFormValid=true
end if

if vUserDate > vDate1 then
IsMyFormValid= false
alert &quot;You must enter a date between: &quot; & vDate & &quot; and &quot; & vDate1 & &quot; .&quot;
exit function
else
IsMyFormValid=true
end if

CC.DataAction.value=&quot;True&quot;
end Function
</script>
 
normally i'd agree with the above post, but sounds like its kinda commercially urgent?

<script LANGUAGE=&quot;javascript&quot;>
function IsMyFormValid(){
var dt_date = new String(CC.date1.value);
if (!dt_date.length){
alert(&quot;You didn't enter a date.&quot;);
return false;
}
var str_temp = new String(CC.Hours.value);
if (!str_temp.length || isNaN(str_temp) || parseInt(str_temp)>23){
alert(&quot;You didn't enter a valid hour value.&quot;);
return false;
}
var str_temp = new String(CC.Minutes.value);
if (!str_temp.length || isNaN(str_temp) || parseInt(str_temp)>59){
alert(&quot;You didn't enter a valid minute value.&quot;);
return false;
}
var vDate = new Date();
var vDate1 = new Date();
vDate1.setDate(vDate1.getDate()+7);
var vUserDate = new Date(dt_date);
if (vUserDate < vDate){
alert(&quot;You must enter a date between: &quot; + vDate + &quot; and &quot; + vDate1 + &quot; .&quot;);
return false;
}
if (vUserDate > vDate1){
alert(&quot;You must enter a date between: &quot; + vDate + &quot; and &quot; + vDate1 + &quot; .&quot;);
return false;
}
CC.DataAction.value = &quot;True&quot;;
return true;
}
</script>

*** untested *** codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Thank you, both of you. The link is very useful and I'm going to use it in the future. But it was commercial urgent, so I really appreciate the Java code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top