View Full Version : submit button uses Onclick but does not validate under w3.org

09-05-2007, 09:03 PM

I am using a form which send users to different url when you select an option. Below is my form and the javascript used.

<form name="Iccy" action="">
Sort By: <select name="blah" class="small">
<option value="http://www.mysite.com/jjskkhkjsl.html">Page1</option>
<option value="http://www.mysite.com/blah.html">Page 2</option>
<script language="javascript">
function go() {
<input type="button" name="test" value="Go!" onClick="go()">

Now the problem is that when I validate my page using the w3.org it shows error stating that the onClick="go()" used is invalid and cannot be used with the doc type. I do not want to change my doctype or anything else and I want my page to validate since all my pages are validated nicely.
Can someone please give me another alternative to my approach. Any other way of sending user to that url but within a form and also be validate with XHTML1.0


09-05-2007, 11:12 PM
language has been depreciated...

<script type="text/javascript">
___ your code _____

also the variable "go" is used by the language itself so you need to create a new variable you can do something like

function goPlace()

09-06-2007, 04:17 AM
Thanks alot buddy

09-06-2007, 06:13 AM
also the variable "go" is used by the language itself so you need to create a new variable you can do something like

I don't think if you override a built-in function with your own it show any error. But it is wise to avoid a built-in function name as you own function name.

<input type="button" name="test" value="Go!" onClick="go()">

You need to put the contents that you've furnished inside the body within the correct container elements like <p>

Moreover you haven't provided the Doctype you've used in your case.

09-06-2007, 05:50 PM
The actual problem was with onClick being in capital letter C. Changing that into onclick gave no errors while validating.

09-06-2007, 06:15 PM
you must be trying to validate it with xhtml.... I would suggest that you do not use the xhtml doctype as it is not supported by IE, and thus you cannot reap the full benefits that it provides, accurately on a consistent basis

09-07-2007, 02:54 PM
well so far my pages have been validated nicely by XHTML 1.0 doc type. And my pages display fine too on every browser. I am making my website cross browser compatible. So if you saying IE does not support XHTML I would like to know in hat situation? Since everything is fine and validating.


09-07-2007, 03:45 PM
whether it validates or not, IE doesnt support it. Read this article