View Full Version : Can't get this AJAX form validation to work

03-08-2007, 10:30 AM

Bear with me please, I'm no javascript expert.

I believe I've followed everything except for knowing where to put:


<script type="text/javascript">
new Validation('form-id');

Does that go in the <head> of my document? Or not? It also says that "he basic method is to attach to the form's onsubmit event" but in the examples and demo I don't see an onsubmit event so I have no idea how to duplicate that.

Like I said, these two areas are the only two I'm a little fuzzy on. I DID download the files and uploaded the two javascript libraries (prototype/validation) to my server and I'm making sure that I use the correct class for each input field.

Any advice would be great!

03-08-2007, 01:54 PM
The link you included is broken, so I'm not exactly sure what that code does.

If you add the checking function to the onsubmit event, it will check the input when the form is submitted, and I would assume since you say its supposed to be AJAX, that it should check the input on the fly, so I don't think you would want to trigger it on the form being submitted.
Oxygen Vaporizer (http://www.vaporshop.com/oxygen-vaporizer.html)

03-08-2007, 05:17 PM
Well, what the....!

Try this: http://tetlaw.id.au/view/javascript/really-easy-field-validation

03-08-2007, 07:20 PM
From looking at the code it looks like you need to place the code in question anywhere in the HTML as long as its below the form that you are validating.
Mazda Mx-5 10Th Anniversary Model Specifications (http://www.ford-wiki.com/wiki/Mazda_MX-5_10th_Anniversary_Model)

03-08-2007, 07:49 PM
Hi - I actually tried that a little bit ago and got it to work but everytime you refresh the page it gives you and "object" error. And that's all it says is "object" error. While at work earlier I had one of our programmers look at it and try to debug the error and he couldn't figure it out. The error was really generic and didn't say much about what needed to be fixed. I started a discussion about this at the google group the developer set up and he gave me a couple more ideas, so I'll see what happens.