Re: DOM-scripting -- FF problem -- SOLVED



maya wrote:
Richard Cornford wrote:
maya wrote:

[...]


You should re-validate server side anyway as you cannot trust anything sent from the client to be valid. Server-side is where any necessary validation is never optional.

Richard.

thank you Richard... I asked in a FF forum, solution was to put 'return false' after function call; have now succeeded in both validate (client-side) and connect to server w/AJAX to send email...:)

button: <button onclick="sendMail(); return false;">submit</button>

sendMail function checks first that validate() method returns true, then does the AJAX stuff....

form is here, http://www.mayacove.com/dev/js/mail.html (won't send email at this location (in real life will be in another domain), but well, if you want to check out the code..)

re validation: my understanding was always that anything you can do client-side you should... ????? what do you mean by I can't trust what's sent from the client? either it validates or it doesn't....;) can you further explain please... thank you again for your help....


Browsers can be configured to have javascript disabled. Some come that way by default (older Blackberry, as I have been informed).

Somebody might come along with NoScript for Firefox, or a browser with JS turned off.

The form should work without javascript. To create a fallback, give the form an action so it can be submitted when javascript is disabled.

A regular form, as a fallback would probably be all you need and would actually have advantages over using Ajax here.

A normal form submission has potential to be accessible to many more users. Besides that, it requires no javascript, so it is simpler and easier to maintain. Not including any script would be much more efficient, too. The page would load faster and use less memory, and especially considering you are using jQuery to facilitate your effects.

A step up from that would be to provide a client-side validation. However, the validation might fail on the lcient, so you need to *revalidate* on the server. That is what Richard was getting at.

But I would advise that the development start with just submitting the form and having that work in as many browsers as possible. After that, you can work on adding a validation script on the server and displaying error messages to the user on that page.

Garrett
.