Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Andrew Young
Andrew Young
Courses Plus Student 639 Points

Form can't submit again after onsubmit return false

So I have the following code

function submitform() {
    var pwd1 = $("#password").val(),
        pwd2 = $("#passwordc").val(),
        errplace = $("#pwderror");
    if (pwd1 != pwd2) {
        errplace.html('<div class="alert alert-danger alert-dismissible fade show" role="alert"><strong>Error!</strong> 兩個密碼不相符<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
        return false;
    } else {
        return true;

which will be called while form submitting by onsubmit='return submitform()', but after I failed once (password wrong), and the functio return false. The form can't be submit anymore whether pressing ENTER key or submit button. How to fix this?

1 Answer

Steven Parker
Steven Parker
215,984 Points

I wasn't able to replicate the issue, it seems to work OK.

I had to guess at the rest of the code, perhaps the actual code is different in a way that might explain the issue.