Page 1 of 1

[SOLVED] Validation not working in Mozilla

Posted: Thu May 13, 2004 5:17 pm
by johnperkins21
Why would this not be working in Mozilla? It works as expected in IE.

Code: Select all

//removed excess code for brevity

<style>
no_margin &#123; margin: 0% 0% 0% 0% &#125;
 TABLE &#123; border-color: #ffffff; border-style: none &#125;
 FONT &#123; font-size: 8pt; color: #000000; font-family: arial,helvetica; &#125;
 INPUT &#123; font-size: 8pt; color: #000000; font-family: arial,helvetica; &#125;
 SELECT &#123; font-size: 8pt; color: #000000; font-family: arial,helvetica; &#125;

 BODY &#123; font-size: 10pt; color: #000000; font-family: arial,helvetica; &#125;
 TD &#123; font-size: 10pt; color: #000000; font-family: arial,helvetica; &#125;

.error &#123;
	FONT-SIZE: 10pt; FONT-FAMILY: arial,helvetica; COLOR: #ee0000; TEXT-DECORATION: none;
&#125;


<script type='text/javascript'>
function validate() &#123;
	if (questionnaire_1.answer1.value == '') &#123;
		document.getElementById('q1').className = 'error';
		alert('Please fill in all the fields');
	&#125;
&#125;
</script>


<form name="questionnaire_1" method="POST" >
  
  <!-- Question #1 -->
  <tr>
    <td width=10 valign="top">
      <b>1)</b>
	</td>
	<td align=left>
	  <span id="q1">Our records indicate that you have visited our website but did not place an order.  Why?</span>
	</td>
  </tr>
  <tr>

  <tr>
    <td>
	  &nbsp;
	</td>
    <td>
	  <input type="button" name="submit" value="Submit" class="textinput" onclick="validate()">
	</td>
  </tr>
I don't even get the alert, and I just don't know what I'm doing wrong. I am not very good a javascript as you can tell.
Thanks for the help.

Posted: Thu May 13, 2004 6:10 pm
by johnperkins21
Figured it out. Needed this:

[syntax=php]if (document.questionnaire_1.answer1.value == '') {

//instead of

if (questionnaire_1.answer1.value == '') {[/syntax]