View Single Post
Old Mar 12th, 2007, 1:49 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
It looks like you have quotes inside your quotes, so to speak, and some odd placement of semicolons. Strictly speaking, though, you shouldn't need to quote any code at all.

Now, it appears as if you want all required values to show up in red, and then to change to black when the user clicks on them. However, you only seem to be doing this for one field, and it seems possible there might be several required fields. Could you perhaps explain exactly what it is you're trying to do? You might be going about it the hard way.

For reference, here's a version of your code that uses functions, rather than strings of executable code. However, I think that there might be an easier way to do what you're trying to achieve.

javascript Syntax (Toggle Plain Text)
  1. function focused() {
  2. if(document.form2.shipfax.value == 'Shipper Fax <--- REQUIRED')
  3. {
  4. document.form2.shipfax.value = '';
  5. document.form2.shipfax.style.color = 'black';
  6. }
  7. }
  8.  
  9. function blurred() {
  10. if(document.form2.shipfax.value == '')
  11. {
  12. document.form2.shipfax.value = 'Shipper Fax <--- REQUIRED';
  13. document.form2.shipfax.style.color = 'red';
  14. }
  15. }
  16.  
  17. function clicked() {
  18. if(document.form2.shipfax.value == 'Shipper Fax')
  19. {
  20. document.form2.shipfax.value = 'Shipper Fax <--- REQUIRED';
  21. document.form2.shipfax.style.color = 'red';
  22. document.form2.shipfax.onfocus = focused;
  23. document.form2.shipfax.onblur = blurred;
  24. }
  25. }
Arevos is offline   Reply With Quote