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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:33:36+00:00 2026-05-13T10:33:36+00:00

Im currently writing some form validation with jQuery and having the followin problem.. I

  • 0

Im currently writing some form validation with jQuery and having the followin problem..

I give ids to my inputs in such a way that when data is posted, i have an array to work with like so..

<input type="text" id="user[name]" />
<input type="text" id="user[email]" />

This means that when the data is posted to my script, i will have a “user” arrau available so i can do things like $user["name"]however, when i try to select the inputs with jquery by doing..var name = $("#user[name]") it wont work. But if i just have the id of the input as “username” then var name = $("#username") will work.

Im assuming its to do with CSS selectors in jquery as it things im trying to access a user object with an ID of name? like the way $("input[username]") would select an input with the id of username.

Any ideas on how i can get around this? And would it work in all browsers?

  • 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-13T10:33:36+00:00Added an answer on May 13, 2026 at 10:33 am

    The id value of a form element is not what gets passed to the server, it is only used internally by the document DOM and scripting languages. It is the name that gets passed.

    Your form elements need to be altered to something like this:

    <input type="text" id="username" name="user[name]" />
    <input type="text" id="useremail" name="user[email]" />
    

    The HTML 4 specification addresses the proper naming of elements:

    ID and NAME tokens must begin with a
    letter ([A-Za-z]) and may be followed
    by any number of letters, digits
    ([0-9]), hyphens (“-“), underscores
    (“_”), colons (“:”), and periods
    (“.”).

    Using square brackets in the name attribute is a common technique to pass data in an array format to the server side scripting language, but using them in an id will certainly confuse JQuery.

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

Sidebar

Related Questions

I'm currently writing some methods that do some basic operations on form controls eg
I am currently writing some unit tests for a business-logic class that includes validation
I'm currently writing an app that posts some data to a HTML form and
I am currently in the process of writing some software in Java that I
I'm currently writing a piece of code that does some searches which returns IDisposable
I am currently writing a simple, timer-based mini app in C# that performs an
I am currently re-writing a dynamic form based on database information. This form contains
I'm writing some code to determine the name that an object is assigned to.
I'm currently writing an AI for a game that is written in c++. The
Currently I am writing some assembly language procedures. As some convention says, when I

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.