rockoyster wrote:
[color=blue]
> Not sure if this is entirely a CSS issue but I have defined the class
> below in CSS.[/color]
To be picky about the subject; classes are defined in (X)HTML. CSS has
selectors which include a way to say "If the element has such and such
class".
[color=blue]
> I am trying to write a javascript script to check that all required fields
> in a form are entered.[/color]
news://comp.lang.javascript would be a better place to ask.
[color=blue]
> The idea was to give all required input fields a class of say "mandatory"
> and then check for fileds with .className=="mandatory"[/color]
[color=blue]
> <input class="mandatory" name="fax" type="text" id="fax" />[/color]
[color=blue]
> alert (tempobj.name);
> alert (tempobj.className);[/color]
[color=blue]
> the first alert displays "fax"
> the second alert displays null.[/color]
With the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>Class & JS</title>
<h1>Class & JS</h1>
<div><input class="mandatory" name="fax" type="text" id="fax"></div>
<script type="text/javascript">
el = document.getElementById('fax');
window.alert(el.name);
window.alert(el.className);
</script>
It works fine, and the class name is displayed. This really is a JS question
and has nothing to do with style sheets. You should try
comp.lang.javascript. It would also be a good idea to post a URI to the
complete webpage. Code fragments are all very well for narrowing down where
you think the problem lies, but when you're wrong its not very helpful.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is