Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:29:14+00:00 2026-05-14T07:29:14+00:00

I’m using the jQuery validate() plugin for some forms and it goes great. The

  • 0

I’m using the jQuery validate() plugin for some forms and it goes great. The only thing is that I have an input field that requires a special validation process. Here is how it goes:

The jQuery validate plugin is called in the domready for all the required fields.

Here is an example for an input:

<li>
    <label for="nome">Nome completo*</label>
    <input name="nome" type="text" id="nome" class="required"/>
</li>

And here is how I call my special function:

<li>
    <span id="sprytextfield1">
        <label for="cpf">CPF* (xxxxxxxxxxx)</label>
        <input name="cpf" type="text"  id="cpf" maxlength="15" class="required" />
        <span class="textfieldInvalidFormatMsg">CPF Inv&aacute;lido.</span>
    </span>
</li>

And at the bottom of the file I call the Spry function:

<script type="text/javascript">
    <!--
        var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1","cpf");
    //-->
</script>

Of course I call the Spry CSS and JavaScript files in the head section as well as my special-validate.js.

When I just use the jQuery validate() plugin and click on the send button, the page goes automatically back to the first mistaken input field and shows the error type (not a number, not a valid email etc.).

But with this new function, this “going-back-to-the-first-mistake” feature doesn’t work, of course, because the validate() function sees it all good.

I already added a rule for another form (about pictures upload) and it goes like this:

$("#commentForm").validate({
    rules: {
        foto34: {
            required: true,
            accept: "jpg|png|gif"
        }
    }
});

Now my question is, how can I add the special validation function as a rule of the whole validation process?

Here is the page to understand it better: link text and the special field is the first one: CPF.

I hope I was clear explaining my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:29:14+00:00Added an answer on May 14, 2026 at 7:29 am

    I’ll answer my own question as I just found the solution.
    I added the JavaScript function to check my cpf number (Brazilian ID number) just before the DOM ready opening like this:

    jQuery.validator.addMethod(
        "cpf",
        function (valor){
            ...
        },
        "CPF inv&aacute;lido"
    );
    

    and then here goes my DOM ready:

    $(document).ready(function(){
        $("#commentForm").validate({
            rules: {
                campocpf: {
                    required:true,
                    cpf:true
                },
            }
        });
    });
    

    If it does interest some Brazilians, I can show the whole function that does the CPF validation (checked with my own number, works). I also have another one for the CNPJ number (Brazilian number for companies).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 420k
  • Answers 420k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In this case your select operation essentially amounts to a… May 15, 2026 at 10:32 am
  • Editorial Team
    Editorial Team added an answer Create two seperate maven prosjectst and bind them with one… May 15, 2026 at 10:32 am
  • Editorial Team
    Editorial Team added an answer Make sure the server also returns the correct HTTP headers… May 15, 2026 at 10:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.