tags:

views:

454

answers:

1

I am using ajaxForm. Now I have encountered a problem. My Idea is when the user enters the username, if any wrong username, it should ReportMessage to the user

My Code is working fine, but the problem is that after ReportMessage shown to the user, the Submit button becomes inactive. So, the user is unable to click the Submit button again.

How to tackle this problem?

$(document).ready(function(){
    $('#myForm').ajaxForm(function(data) {
        if (data==1){
            $('#bad').fadeIn("slow");
        }

    });
});

...

<body>
    <p id='bad' style="display:none;">Please enter a valid username</p>
</body>

...

<form id="myForm" action=" " method="post"> 
    <center> <input type="submit" id="submitinput" value="Submit"/> </center>
</form>

...

+1  A: 

You might want to try catching the submit event on the form and then using ajaxSubmit. Like this:

$('#myForm').submit(function() {
    $(this).ajaxSubmit(function (data) {
         if (data==1){
             $('#bad').fadeIn("slow");
         }
    });

    return false;
});

It'll probably sidestep whatever funny business you're experiencing.

Allain Lalonde