View Full Version : Another newbie... cross browser forms

01-15-2004, 12:14 AM
Having my first go at forms, being a MacOSX user on Dreamweaver MX, was checking thru Safari and all my validation coding was working fine. Then when I checked in Explorer and Navigator, validation was seen to be not working. Is there an easy answer? Have I missed something?
Regards all

01-15-2004, 12:54 AM
Forgot to add my url
This is just a test page

01-15-2004, 04:46 AM
You have two form tags:

<form action="http://www." method="POST">
<form name="formcheck" onsubmit="return formCheck(this);">

01-15-2004, 07:59 AM
Thank you for your reply.
I am assuming that I only have to remove the second "<form" and leave it as "name="formcheck"..."
Will work on that when I am back at the office.

01-15-2004, 08:11 AM
Remove the first form tag.

<form action="http://www." method="POST">
<form name="formcheck" onsubmit="return formCheck(this);">

01-15-2004, 01:16 PM
Thanks Glenn
But when I finally want to enter URL for "form action...POST' how? Or should it go elsewhere?

01-16-2004, 12:15 AM
Having removed the rogue line, now works in Navigator as well as Safari, but still not in Explorer (just get a new clean page of the same).
Also referring back to previous post re form action to cgi-bin.
I'm almost there... I think. Thanks guys in advance.

01-16-2004, 04:41 AM
<form action="YOUR URL HERE" name="formcheck" onsubmit="return formCheck(this);" method="POST">

Moved the action and method into one form tag.

01-16-2004, 05:00 AM
Great Oakendin thanks.

Still not solving my problem why the validation doesn't work in Explorer, if anyone can see why.

01-16-2004, 01:54 PM
To where are you posting? You have to change the form tag given you by Oakendin to the URL of your processing page. Also, regardless of whether the values are all valid, your script seems to be returning false.

Also: formElement.type *is* defined for radios and checkboxes, and should be definite cases in your switch statement. The validation you've got in your case "text" and "textarea" won't fly, should I happen to type two spaces into the field - an invalid response. Use a trim function like these:

String.prototype.lTrim = function () {
var whitespace = new RegExp("^\\s+","gm");
return this.replace(whitespace, "");

String.prototype.rTrim = function () {
var whitespace = new RegExp("\\s+$","gm");
return this.replace(whitespace, "");

String.prototype.trim = function () {
return this.rTrim().lTrim();
or this:

function Trim(str) {
return str.replace(/^\s+/gm).replace(/\s+$/gm);

I'm sure this latter option can be combined into a better algorithm, but the above set of prototype options works best for me.

All that being said, it works just the same in IE6w as it does in Opera7w; it's long been known that IE5m is (while a great rendering engine and a pioneer in CSS) one of the buggiest browsers around. I'd be surprised to find out that it has a greater market share than any other Mac browser.

01-16-2004, 10:25 PM
Thank you Choopernickel
At least now having a URL has made some difference even if it is not absolute at the moment.

Where exactly should that code you posted be placed?

Don't know if it was another problem, but I did have:

if (alertMsg.length == l_Msg){
alert("Your tips have been submitted")
return false;
return false;

so I changed the first false to true... OK?

One day I wil understand all of this a lot better :D (Approaching my 60's and learning is slow)

Appreciate this help! :thumbsup: