views:

75

answers:

3
<script type="text/javascript">
    jQuery.validator.addMethod("steam_id", function(value, element) {
        return this.optional(element) || /^STEAM_0:(0|1):[0-9]{1}[0-9]{0,8}$/.test(value);
    });
    jQuery.validator.addMethod("nome", function(value, element) {
        return this.optional(element) || /^[a-zA-Z0-9._ -]{4,16}$/.test(value);
    });
    $().ready(function() {
        var validator = $("#form3").bind("invalid-form.validate", function() {
            $("#summary").html("O formulário contém " + validator.numberOfInvalids() + " erros.");
        }).validate({
            debug: true,
            errorElement: "em",
            errorContainer: $("#warning, #summary"),
            errorPlacement: function(error, element) {
                error.appendTo(element.parent("td").next("td"));
            },
            success: function(label) {
                label.text("").addClass("success");
            },
            rules: {
                steamid: {
                    required: true,
                    steam_id: true
                },
                username: {
                    required: true,
                    nome: true
                },
                nickname: {
                    required: true,
                    nome: true
                },
            }
        });
    });
</script>

Well, my question is, how do I submit this form to php. I want to insert a thing in a databse and I have a phpscript for that, but with this validation I can't do that.

Can you tell me how submit using jquery?

A: 

You can submit a form using jQuery by calling .submit();

Example: $("#form3").submit();

Reference: http://api.jquery.com/submit/

Peter Forss
It doesnt work for me, when I put that the Ok images appear and doesnt't do anything, can you help me?thanks!
Afonso
A: 

I'm using the jquery validation plugin from bassitance

Afonso
Write a comment on your own question instead of posting it as an answer. (You probably clicked the wrong textarea...)
BoltClock
Ok, thanks for you answear, I'lldo that always from now on
Afonso
A: 

The problem is here:

debug: true,

When you have the debug property set to true, it actively prevents form submission...for debugging, so you can test your validation rules but never trigger a postback. It's purely for testing. Once you've got validation how you want it and you want to move to actually submitting the form (where you're at!), remove the debug setting (or set it to false).

As a side note, $().ready(function() { is deprecated in jQuery 1.4+, instead you should use one of these:

$(document).ready(function() {
//or:
$(function() {
Nick Craver