Nothing happens when I click next #14

Closed
macaddict89 opened this Issue Feb 10, 2012 · 8 comments

3 participants

@macaddict89

I have a form created with the validation at the end of the page. When I click next, nothing happens in Chrome or Firefox. I am not sure how to debug javascript. Do you know what could be causing this? I'm running locally on MAMP in a php file.

@rickharrison

Could you please post some code or a link to some code so I can help debug.

@rickharrison

You have a bug in your callback that you are passing to the FormValidator object.

function(errors, events) {
    if (errors.length > 0) {
        el.innerHTML = errors.join('<br />');
    }
}

You refer to a variable named el but it does not exist. This throws an error which then prevents the form from being stopped on its default behavior.

@macaddict89

Well I took that code from your example page. Your documentation is really aimed at knowledgable people, but there are people that do not understand javascript trying to implement form validation. I even used your exact code including your CSS from the example page and it just continued to the next page.

I'm sorry I've just been through multiple validation scripts and can't get any to work, and am not yet comfortable enough in javascript to know what is going wrong. I understand that this is probably a free-time script you made, but this PHP project is a free time thing and I don't have time to delve into javascript.

@rickharrison

I didn't mean to be terse in any of my responses. You are correct that this is a free-time thing, but I am more than happy to help anyone get up and running using it!

So the el is referring to a dom element that needs to be selected in the javascript. You can do this like so:

var el = document.getElementById('error_box')

This would select the element in the html with an id of "error_box" like so:

<div id="error_box"></div>

Please let me know what questions you have.

@macaddict89

thanks. Do I set that el in the script right before /body?

@rickharrison

You should do that either in the callback function or in the script above where you define the FormValidator object.

@sikdave

Thank you very much for this. This clarification helped me a lot as a beginner Javascript user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment