|
Posted by Gιrard Talbot on 02/05/06 14:34
JF01 wrote :
> Hi,
>
> I have an XHTML page with the following DTD Declaration: <!DOCTYPE
> html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> Inside, I have a form with the following format:
>
> <form action="login.asp" method="post" id="frm1">
> <input type="text" size="30" name="email" id="email">
In strict DTD, the content of form elements must be block-level elements
except another form. So,
<form action="login.asp" method="post" id="frm1">
<p> <input type="text" size="30" name="email" id="email">
(...)
or
<form action="login.asp" method="post" id="frm1">
<div> <input type="text" size="30" name="email" id="email">
(...)
> <input type="button" value="Register" class="formbutton1" id="submit1"
> name="submit1" onclick=javascript:callsubmit();>
onclick="callsubmit();"
Attribute values must be quoted in XHTML (also recommended in HTML 4);
you can declare default script language with
<meta http-equiv="Content-Script-Type" content="text/javascript" />
in the <head> section. The "javascript:" part is not needed.
Also, if the button is a submit button, then why not use a submit button?
E.g.:
<input type="submit" (...)
>
> Inside the <head> tag, I have the following javascript:
>
> <script type="text/javascript">
> function callsubmit()
> {
>
> var pwl = frm1.pass.value.length;
var pwl = document.getElementById("frm1").pass.value.length;
This mistake is frequently encountered:
Using Web standards in your web page:
Accessing Elements with the W3C DOM
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access
Where is your pass form control input? It must be declared somewhere.
>
> if (frm1.email.value == "")
> {alert("The e-mail field is required");}
>
> else
> {frm1.submit();}
> }
Everywhere you have frm1, you should have first - to begin with -
declared this in your script:
var frm1 = document.getElementById("frm1");
> </script>
>
> This is designed as a very simple form validation script, and it works
> perfectly in IE6, but in Firefox 1.5, the javascript does not run. Can
> anyone suggest how I can make the script compatible with both browsers?
Bookmark these 2 pages for your Firefox issues/problems:
Using Web standards in your web page:
http://www.mozilla.org/docs/web-developer/upgrade_2.html
Mozilla Web author FAQ
http://www.mozilla.org/docs/web-developer/faq.html
More on accessing forms and form elements:
Referencing Forms and Form Controls by comp.lang.javascript newsgroup
FAQ notes
http://jibbering.com/faq/faq_notes/form_access.html
DOM 2 specification on accessing forms and form elements
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-40002357
GΓ©rard
--
remove blah to email me
Navigation:
[Reply to this message]
|