Home Forums Plugin Support WP User Frontend Pro Form Validation

This topic is: resolved

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14110

    Jamie
    Member
    Post count: 32

    I have 6 fields that I need the user to input at least one before the form can submit. I've attempted to do this with jQuery however the form is still submitting and I think this is due to the ajax submission. I can't put the required attribute because only one of them is and it could be any one.

    Is there a way I can say if fields 1-6 are empty, add a notice to the form and stop submission?

    Also I have searched to find an answer to this on this forum but I can't. I am using this plugin to allow users to submit woocommerce products and I have a few number fields. I saw you mentioned a number field but I do not have a number field for a custom field.

    I am using the latest 2.1.8 pro version.

    Thanks.

    #14233

    Jamie
    Member
    Post count: 32

    Anyone?

    #14235

    Jamie
    Member
    Post count: 32

    Turns out I was able to make this work.

    For those that need to know how to do this kind of validation I used the following jQuery

    $('.wpuf-submit input').click(function(){ 
        var test_val = $.trim($('#input_id_here').val());
        var test_val2 = $.trim($('#input_id2_here').val());
        if ((test_val === '') && (test_val2 === '') { 
            $('.wpuf-form').append('<li class="has-error">Put your validation error in here.</li>'); 
           return false; // stops the form submitting. 
        }
    });

    You just add as many text inputs as you need and add them to the if statement.

    #14236

    Tareq Hasan
    Keymaster
    Post count: 2831

    Hi Jamie, sorry I hadn't noticed this topic. Glad to know that you were able to solve this by yourself.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Form Validation’ is closed to new replies.