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

  • Home
  • SEARCH
  • 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 1112499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:43:11+00:00 2026-05-17T02:43:11+00:00

I am using jQuery to create a client-side validation function for a .NET form.

  • 0

I am using jQuery to create a client-side validation function for a .NET form. Each form element has an id and several of the form elements are required fields.

In my validation script, I thought of creating an array of the id’s of the ‘not required’ elements, then on every ‘blur’ event checking whether or not the current element ($(this)) is part of the array of elements not to check, but it doesn’t seem to be checking against the list.

function validate(){

  $('.form_wrapper input').blur(function(){
    var isEmpty = $(this).val();
    var isRequired = $(this).attr('id');
    var notRequired = ['txtHomePhone','txtWorkPhone','txtMobile','txtStreetAddress','txtSuburb'];

  if (isEmpty == "" && isRequired == notRequired){
        // run conditional validation stuff
        }
        else {
        // run other conditional validation stuff       
        }

    });

}

The area I think I need help with is the if statement checking whether or not the current form element is part of the array of id’s not to validate. I am also not really sure if it’s actually an array I want/need to use in this situation?

Any help would be great,

Thanks,
Tim

  • 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-17T02:43:12+00:00Added an answer on May 17, 2026 at 2:43 am

    not exactly sure here, but wouldn’t you want to be doing

    $.inArray(isRequired,notRequired) >= 0
    

    instead of

    isRequired == notRequired
    

    EDIT

    $.inArray() returns -1 if no match is found. Modified code to correctly show this behavior.

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

Sidebar

Related Questions

I am using the JQuery Validation plugin for client side form validation. In addition
In VS2010 and ASP.NET MVC 2, it seems that client-side validation (JQuery Futures or
I'm using jQuery UI to create a button to a given html element. I'm
I'm using jQuery Cycle to create several slideshows on the same page. Some of
I'm usually a C# developer, but writing a mostly-client side application using jQuery. It
I am designing webpage using jquery and php. My page has side menu, and
I'm using a YUI datatable to create some basic client side sorting for some
I am trying to create a simple ajax chat using JQuery and ASP.NET. My
i am using asp.net-mvc3 helpers and the jquery validation plugin (what comes out of
I am using the CI validation class to do server-side validation and Jquery validation

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.