Hi there.
I'm working on a quiz where you can submit another time your answers
(yes, I want them to win ;-).
But if you do so, I'd like to display a warning that tells you that
you have already submitted and that your new submission will erase the
previous one.
I've used the remote feature on the 'name' field to check if a user
has already submitted : with success but then, the form is locked and
I can't submit until I fill an unplayed 'name'.

#1 So, can I use the remote feature to check a returning player but
still allowing that user to submit?


I hide my custom warning <div> at start and displays it if 'remote'
triggers.

#2 How can I hide that <div> if the user change its name?


Here is my script, thanks a lot for your advices :

$(document).ready(function(){
        $("#alreadyplayed").hide(); // this is my <div> warning telling you
that you have already played
        $("#formQuiz").validate({
                rules: {
                        name: {
                                required: true,
                                remote: {
                                        url: "scripts/namecheck.php", // checks 
if 'name' has already
played
                                        type: "post"
                                }
                        }
                },
                messages: {
                        name: {
                                required: "required",
                                remote: function(){
                                        $("#alreadyplayed").show(); // displays 
my custom <div> warning
                                        return "You already played!" // display 
the regular 'remote'
error message
                                }
                        }
                },
                submitHandler: function(form) {
                        form.submit();
                }
        });
});

Reply via email to