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

Simple Java Script works in IE but not Firefox - PLEASE HELP

Status
Not open for further replies.

dv8er88

Programmer
Feb 21, 2005
42
US
Hi I don't know much about Java but I have been using the following script for Field validation and it works fine in IE. Can someone please tell me how to get this to work for both.

Thanks in advance.


<script>

function DoSubmit()
{
if (document.all.bill_name.value == '')
{
alert("Please enter valid name.")
}
else
{
document.form2.submit()
}
}
</script>


<form name="form2" method="post" action="ok.html">

Name: <input name="bill_name" type="text" size="30" />
<input type="button" name="Submit22" onClick="DoSubmit()" value="Submit" />

</form>

 
the "all" collection is IE-only. try this:

Code:
function DoSubmit() {
    var f = document.forms['form2'];
    if (f.elements['bill_name'].value == '') {
        alert("Please enter valid name.");
    } else {
        f.submit();
    }
}



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi,
First I wanted to say thanks to cLFlaVA for spending more time helping me then coming up with sarcastic comments.
Thanks so much for the help cLFlaVA.

I do know there is a difference between Java and Java Script. I made a typo, it was late,

Also this code is actually part of a much bigger Cold Fusion page. That post to another Cold Fusion page. In the interest of simplifying thing I posted the above sample.
 
they weren't being sarcastic. both Dan and Jeff made valid points that you should take into consideration. Based on the information you gave, Dan's comment is something you should have taken to heart, and Jeff was trying to make sure you knew there was a difference.

No need to get offended.



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
dv8er88,

My comments were not sarcastic in the least. I had a genuine desire to know how you accessed POSTed form fields in an HTML page.

Knowing Jeff as well as I do, I know that he wasn't trying to be sarcastic either. In fact - no-one who has posted to this thread - except you in your last post - has been anything other than genuinely nice.

Perhaps you shouldn't jump to hasty conclusions.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
No harm done [smile]

It's easy to misunderstand one another when we use merely text. Normally we communicate with one another on many different levels (and if we were face-to-face it may have been more obvious we weren't attempting to be sarcastic).

I was just thinking about Dan's comment about catching POST form submits using html files and came up with an answer for that. Just because the file extension is .html doesn't mean it's necessarily a static html file (you could be rewriting the file extensions server-side so they *appear* to be static html files - but may be something like PHP, CFM etc).

As I said before... no harm done... no foul.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
OK, I misunderstood. I thank you all for the time spent the help and explanations.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top