M
Mike the Canadian
I am having a strange problem with field verification in a form. The
JavaScript below works just fine in Firefox but in IE. "license" is a
pull-down list and "requiredDiscount" is a text field. When license is
"Freeware" and requiredDiscount is "N/A", in IE (but not Firefox) you
get the message "For trialware you must enter a valid discount". It
seems that in IE "this", the form, is not set. I also tried using
"document.form" instead of "this" but then you can have
requiredDiscount as "N/A" when license is not "Freeware". Can anyone
explain what is wrong here?
-------------------
<html><head>
<script language="javascript">
<!--
function submitIt(form){
var licChoice = form.license.selectedIndex
var sDiscount = form.requiredDiscount.value
if ((form.license.options[licChoice].value == "Freeware") &&
(sDiscount != "N/A")){
alert("For freeware you must enter a discount of N/A")
return false
}
sDiscount = sDiscount.toUpperCase()
if ((sDiscount == "N/A") && (form.license.options[licChoice].value
!= "Freeware")){
alert("For trialware you must enter a valid discount")
return false
}
return true
}
-->
</script>
</head>
<body>
<form onSubmit="return submitIt(this);" action="list.cgi"
name="submitForm" method="post"
enctype="application/x-www-form-urlencoded">
[...]
Non-profit Discount: (e.g.: 10% - enter N/A for freeware)<br>
<textarea name="requiredDiscount" rows="3"
cols="61">N/A</textarea><br>
Software license:<br>
<select name="license"><option
selected="selected">Time-limited trial</option><option>Feature-limited
demo</option><option>Commercial</option><option>Freeware</option></select>
[...]
_______
Trade your DVDs, movies and CDs for Free!
http://www.dvdtrades.net
JavaScript below works just fine in Firefox but in IE. "license" is a
pull-down list and "requiredDiscount" is a text field. When license is
"Freeware" and requiredDiscount is "N/A", in IE (but not Firefox) you
get the message "For trialware you must enter a valid discount". It
seems that in IE "this", the form, is not set. I also tried using
"document.form" instead of "this" but then you can have
requiredDiscount as "N/A" when license is not "Freeware". Can anyone
explain what is wrong here?
-------------------
<html><head>
<script language="javascript">
<!--
function submitIt(form){
var licChoice = form.license.selectedIndex
var sDiscount = form.requiredDiscount.value
if ((form.license.options[licChoice].value == "Freeware") &&
(sDiscount != "N/A")){
alert("For freeware you must enter a discount of N/A")
return false
}
sDiscount = sDiscount.toUpperCase()
if ((sDiscount == "N/A") && (form.license.options[licChoice].value
!= "Freeware")){
alert("For trialware you must enter a valid discount")
return false
}
return true
}
-->
</script>
</head>
<body>
<form onSubmit="return submitIt(this);" action="list.cgi"
name="submitForm" method="post"
enctype="application/x-www-form-urlencoded">
[...]
Non-profit Discount: (e.g.: 10% - enter N/A for freeware)<br>
<textarea name="requiredDiscount" rows="3"
cols="61">N/A</textarea><br>
Software license:<br>
<select name="license"><option
selected="selected">Time-limited trial</option><option>Feature-limited
demo</option><option>Commercial</option><option>Freeware</option></select>
[...]
_______
Trade your DVDs, movies and CDs for Free!
http://www.dvdtrades.net