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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:55:49+00:00 2026-05-22T11:55:49+00:00

My validation script I have written takes the name attribute from an input tag

  • 0

My validation script I have written takes the name attribute from an input tag and puts it in an alert if that input is required and not filled out. EX:

<input type="text" name="dateRequested" class="required" />

So if this wasnt filled out by the user, they would see an alert saying ‘dateRequested’ is a required field. Having no space looks ugly, so, simply, I would like to know if it is possible to have a space in the name attribute….ex: name=”Date Requested”. And if this is possible, is it bad practice?

  • 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-22T11:55:50+00:00Added an answer on May 22, 2026 at 11:55 am

    Yes it is possible. (The name attribute is defined as containing CDATA which is “pretty much whatever the heck you like”*)

    No, it isn’t bad practise. Well, not terrible practise. It might come back to bite you later though.

    However … I would approach this by getting the id of the input, finding the <label> with a matching for attribute, and using the text content of that. Labels are designed for human friendly labels, names are not. (Using jQuery (and not testing) for laziness: $('label[for="' + $(this).attr('id') + '"]').text())

    Footnote: * counter intuitively there is a NAME token which is not what the name attribute takes, but it what the id attribute uses. There is also an ID token (which the id attribute doesn’t take because it takes a NAME token).

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

Sidebar

Related Questions

I am learning AJAX and have borrowed a script from NETTUTS Codeigniter from Scratch:
I have a very strange issue that only affects webkit browsers for some reason,
I have made a function that validates inputs with for different kind of strings.
I've got this validation script for my form (a survey). It loops through all
I have some custom validation I'd like to do with jQuery. jQuery validation comes
I have been trying to make sense of some claims that Appcelerator Titanium makes.
I have a text box which accepts time(max of 5 characters only), and a
I have experienced a weird problem with javascript. The problem page uses some jQuery
I'm trying to work out how to go about checking a text area to
Been struggling with this for a couple days now. Here's the set up -

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.