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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return ???

Status
Not open for further replies.

deystath

Technical User
Jan 14, 2001
1
0
0
GR
hi
i want some help with the following javascript:
<script language=&quot;javascript&quot;>
function goToURL() { window.location = &quot;online_krat_reply_mainfr.htm&quot;; }
function validate(){
var digits=&quot;0123456789&quot;
var temp

if (document.testform.textfield.value==&quot;&quot;){
alert(&quot;No Name !&quot;)
return false
}
if (document.testform.textfield3.value==&quot;&quot;){
alert(&quot;No Age!&quot;)
return false
}
for (var i=0;i<document.testform.age.value.length;i++){
temp=document.testform.age.value.substring(i,i+1)
if (digits.indexOf(temp)==-1){
alert(&quot;Invalid Age !&quot;)
return false
}
}
return ??? ->problem
</script>
if first two conditions are false i want to go to another url.What should i write in the line before the last one to do that???
Note:this script was born from a mix of other two scripts: 1)defines the gotourl function
2)validates fields before submitting.
What i want to do is that when all fields are completed and submit button is pressed then go to another url.
Hope for your answer!
Thanks



 
Why all that, you can do the following for example:

<Script language=&quot;JavaScript&quot;>

function validate(frm)
{
if (frm.i_name.value == &quot;&quot;) return false;
if (frm.i_age.value == &quot;&quot;) return false;
return true;
}

</Script>

<body>

<form action=&quot;yoururl&quot; method=&quot;post&quot; onSubmit=&quot;return validate(this)&quot;>

<input type=&quot;text&quot; size=&quot;30&quot; name=&quot;i_name&quot;><br>
<input type=&quot;text&quot; size=&quot;10&quot; name=&quot;i_age&quot;><br>
<input type=&quot;submit&quot; value=&quot;Send&quot;>

</form>

</body>



That was a piece of code. I hope that what you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top