| Programming | Newsgroup Tips & Tricks | CubeCart Stuff |
| Subject: Javascript question |
| From: mscurto@gmail.com |
| Date: 23 Aug 2005 13:01:12 -0700 |
| Newsgroups: alt.html |
| X-Mozilla-Status: 0001 |
| X-Mozilla-Status2: 00000000 |
| Path: bigbe1.bellsouth.net!bigfeed.bellsouth.net!news.bellsouth.net!news.glorb.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail |
| Newsgroups: alt.html |
| Organization: http://groups.google.com |
| Lines: 46 |
| Message-ID: <1124827272.796659.104770@g47g2000cwa.googlegroups.com> |
| NNTP-Posting-Host: 207.148.213.85 |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset="iso-8859-1" |
| X-Trace: posting.google.com 1124827279 15840 127.0.0.1 (23 Aug 2005 20:01:19 GMT) |
| X-Complaints-To: groups-abuse@google.com |
| NNTP-Posting-Date: Tue, 23 Aug 2005 20:01:19 +0000 (UTC) |
| User-Agent: G2/0.2 |
| Complaints-To: groups-abuse@google.com |
| Injection-Info: g47g2000cwa.googlegroups.com; posting-host=207.148.213.85; posting-account=cP8TFA0AAAAuOWoz-ocasNMUMLazDcnO |
| Xref: bigfeed.bellsouth.net alt.html:636602 |
I am new to Javascripting and I am teaching myself. I have some simple
code here I need help with.
It works fine however if a user enters in data in one text box but not
the other, an error message appears (which is correct). Is there a way
to keep the entered textbox value if the error message pops up? In
other words, If I enter in text in the 'Hourly' textbox but not the
yearly, once I hit continue, is there a way to prevent the data from
disappearing in the 'Hourly' textbox?
Thanks in advance for your help.
<html>
<head>
<script type="text/javascript">
function checkMoney(){
var text1=jsform.txt1.value
var text2=jsform.txt2.value
if (jsform.txt1.value == "") {
alert("Missing Data in Field 1")
}
else if (jsform.txt2.value == "") {
alert("Missing Data in Field 2")
}
else { alert("Successfully submitted!")
}
}
</script>
<title>
</title>
</head>
<body>
<form name="jsform" method="post" onsubmit="return checkMoney()">
Hourly<input type="textbox" name="txt1"><br>
Yearly<input type="textbox" name="txt2"><br>
<input type="submit" name="submit" value="continue"><br>
</form>
</body>
</html>