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 6841573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:59:01+00:00 2026-05-26T23:59:01+00:00

im trying to validate my form, but for some reason the SSN field wont

  • 0

im trying to validate my form,
but for some reason the SSN field wont work 🙁

i have:

    validate: function () {
        contact.message = '';
        if (!$('#contact-container #contact-name').val()) {
            contact.message += 'Name is required. ';
        }

        var ssn = $('#contact-container #contact-ssn').val();
        if (!ssn) {
            contact.message += 'SSN is required. ';
        }
        else {
            if (!contact.validateSSN(ssn)) {
                contact.message += 'SSN is invalid. ';
            }
        }

        var email = $('#contact-container #contact-email').val();
        if (!email) {
            contact.message += 'Email is required. ';
        }
        else {
            if (!contact.validateEmail(email)) {
                contact.message += 'Email is invalid. ';
            }
        }

        if (!$('#contact-container #contact-message').val()) {
            contact.message += 'Message is required.';
        }

        if (contact.message.length > 0) {
            return false;
        }
        else {
            return true;
        }
    },

and

            validateSSN: function (ssn) {
            // 
            if (!/^[0-9]{9}$/)
                return false; 
                    else 
                    { 
                       return true;
                    }

    },

The e-mail section i have works fine, but the SSN section just accepts anything along as its not empty. What am i missing?
thank you

  • 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-26T23:59:02+00:00Added an answer on May 26, 2026 at 11:59 pm

    !/^[0-9]{9}$/ will always return false since the /…/ part evaluates to a regex object and an object is always evaluated to true.

    You probably want to if (!/^[0-9]{9}$/.test(ssn))

    EDIT: Even simpler:

    validateSSN: function (ssn) {
      return /^[0-9]{9}$/.test(ssn);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate my php form using exception, but somehow it doesn't work.
I'm trying to validate some of the field in my form. and I want
I am trying to validate some form fields but it always errors out on
I have not really used JavaScript before but I am trying to validate form
I'm trying to validate some form fields using JS functions, but they don't seem
I'm trying to validate some form data before adding it to a database however
i have been trying to validate This Form: <table> <form action=test.html method=post id=contactform name=contactform>
I have a strange problem. I am trying to validate one form sent through
I'm trying to validate a field with comma separated list of strings(particular form) or
I have a jQuery Dialog form and on submit I'm trying to validate the

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.