Colored text in alert box

or put code tags around your code:
[ code ] here your code [ /code ]
(without the spaces)

Sorry couldn’t respond yesterday.

Here is my code which is not working in Firefox or netscape, but working fine in IE


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled</title>
<style type="text/css">
.titlebar {
      color: #fff;
      font-weight:bold;
      background-color: #ff0000;
      padding:2px;
      text-align:left;
}			
.msgbox {
      border:outset 2px #fff;
			background-color: #fff;
			width:250px;
			color: #000;
			font-family: verdana,tahoma,arial,helvetica,sans-serif;
			font-size:10pt;
			text-align:center;
}
.cross {
			color: #000;
      border:outset 2px #fff;
      background-color:#ccc;
      float:right;
      margin:0;
      width: 1.2em;
      line-height: .8em;
      padding-bottom: .2em;
      cursor:pointer;
      text-align:center;
}
.innerText{
			padding-left:30px;
			text-align:left;
			color: #ff0000;
}			
#testzone {
      position:absolute;
      top:100px;
      left:200px;
}
#trap {
      padding:0px 1px;
      margin: 5px 0px;
}
</style>
<script type="text/javascript">
 function validate() {
  var msg = '';

  var oNv=document.orderform.Name.value;
  var oAv=document.orderform.Address.value;


	if(oNv==''){ msg +="Please enter your name<br />";}
	if(oAv==''){ msg +="Please enter your address<br />";}
				


   if(msg == '') {return true};
   else { document.getElementById('testzoneMsg').innerHTML=msg;
          document.getElementById('testzone').style.display='block';
          return false; }
  }
  </script>
</head>
<body>
<div id='testzone' class="msgbox" style="display:none;" >
 <div class="titlebar">
  <div class="cross" onclick="document.getElementById('testzone').style.display='none';">x</div> Warning !
 </div>
<div class='innerText' id="testzoneMsg">
</div>
<div>
<input type="button" id="trap" value="ok" class="button" onclick="document.getElementById('testzone').style.display='none';" />
</div>
</div>
<br>
<br><form name="orderform" method="post" onSubmit="return validate();">
<input type="text" size="40" name="Name" value="">
<br>
<br><input type="text" size="40" name="Address" value="">
<br>
<br><input type="submit" name="Submit" value="Submit" >
</form>
</body>
</html>

By the way, I cannot find a # anywhere on this page at this moment and I am in advanced reply. Is it a setting that I have to select somewhere?

Cheryl

You’re probably using the Basic Editor (as I am). Just wrap with the BBcode and you’ll be all good.

BTW, you need a slash in your BBtag up there. The last one should be

. ;)

Sorry, I forgot you could turn that off. Mine’s set to standard which is the default.

It’s working in IE but not Firefox or Netscape because you have an error that IE just ignores.

 if(msg == '') {return true};

should be

 if(msg == '') {return true;}

Thank you very much kravvitz, now it does work. I am so naive I thought that the semicolon had to go after everything in javascript. I guess I will never get a proper handle on it.

Cheers Cheryl

You’re welcome. :slight_smile:

JavaScript doesn’t require semicolons the way other languages like PHP do.
In JavaScript you can use semicolon and/or a new-line to separate statments.
Semicolon’s don’t go after conditionals or loop statments, excpet for with the rarely used do/while. Semicolons do not go after curly braces.