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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:08:15+00:00 2026-06-19T03:08:15+00:00

I am building a responsive form and using css media queries to update layout

  • 0

I am building a responsive form and using css media queries to update layout based on screen width.

Between the desktop view and the mobile & tablet views, the design for the form changes in that the label elements sit atop the input fields in desktop width, but then become the default input field values when the screen is reduced to mobile width.

I am running the following function to put text in the labels as a value of the input fields:
HTML:

    <div class="sectionHeader" id="updateDetails">My details <span class="sectionEdit">Edit</span></div>
        <div class="sectionWrapper" id="myDetails">
            <div class="formSection clearfix">
                <fieldset>
                    <legend>Personal</legend>
                        <div class="ctrlHolder">
                            <div class="ctrlHolder">
                                <label class="hiddenLabel" for="givenName">Given name</label>
                                <input name="givenName" id="givenName" type="text" class="text long required"/>
                            </div>
                            <div class="ctrlHolder">
                                <label class="hiddenLabel" for="familyName">Family name</label>
                                <input name="familyName" id="familyName" type="text" class="text long required"/>
                            </div>
                        </div>
                </fieldset>
            </div>
        </div>
<div class="formSectionFooter clearfix">
    <input data-target="myInvestment" class="sectionNavigator button secondary" id="sectionDetailsNext" name="sectionDetailsNext" type="button" value="Continue"/>
            </div>


$('#details .formSection fieldset .ctrlHolder label').each(function(){
   //console.log($(this).text());
   $(this).addClass('hiddenLabel');
   $(this).next('input').val($(this).text());
});
}

This is playing havoc with my client side validation as the fields are being tested for emptiness and they become full and error on the default values. Among other things the validation checks for empty fields or default values (such as ‘Select’, ‘First name’, etc)

$('.sectionNavigator').click(function(event){
    //$(this).closest('.formSection').validate();
    validateMy.form();
    event.preventDefault();

    // check for any empty fields in the preceding section
var $thisFormSection = $(this).closest('.formSection');
var $elementsWithErros = $thisFormSection.find('input[value=""]:visible, input[class="error"]:visible, select[value="Day"]:visible, select[value="Month"]:visible, select[value="Year"]:visible, select[value="Select"]:visible, select[value="Please select"]:visible, select[value="Given name"]:visible, select[value="Family name"]:visible');
var target = $(this).attr('data-target');

Does anyone have any advice on how to approach this?

  • 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-06-19T03:08:16+00:00Added an answer on June 19, 2026 at 3:08 am

    So basically you want the field to be treated as “empty” if it has the default value and hasn’t been edited by the user.

    First, you can use the placeholder attribute instead of setting the val. It’s now supported by most of the mobile browsers and shouldn’t brush up against your validation. For the cases where it’s not supported—and if you’re going to go this route, make sure you only do this in browsers where it’s not supported—you can track which fields have been edited. When performing your validation, if a field has been edited and is the default value, then that’s an error. Otherwise you can just assume it’s empty.

    Just want to say, I think that validation (‘no default values’) is unnecessary, especially since you’re talking about mobile devices and the additional cost of performing this logic is probably just not worth it.

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

Sidebar

Related Questions

I am building a website which I would like to behave responsively using CSS
I am building a Form object using pyramid_simpleform. I would like to have one
I am using a model-based form to create a form based off a data
I'm building a responsive website so I've been reading about css sprites on mobile
building a site using PHP and MySQL that needs to store a lot of
I've successfully installed this jQuery-based signup form here: http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/ But when I applied it
I am building a login form. If the user attempts to login with invalid
I'm building a website with codeigniter and I'm creating a form for user submission.
I'm building a contact form that uses ajax via jQuery to fetch a CAPTCHA
I am building a form that interacts with third party API via JSON. My

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.