You are viewing limited content. For full access, please sign in.

Question

Question

How can I hide the Country label in a Form?

asked on May 13, 2015

I read in another thread that this would work.

.Country+label, .Country {display:none;}

However, in my implementation this is hiding the input field for "Country" but it leaves behind the label for "Country." What CSS can I use to hide the label AND the input field?

0 0

Answer

APPROVED ANSWER
replied on May 13, 2015

Please see this help page. You can use this javascript.

$(document).ready (function () {
  $(".Country").parent().children().css('display', 'none');
})
2 0
replied on April 15, 2016

Alexander,

This is not saving correctly to Laserfiche

0 0
replied on April 15, 2016

Get the id of the Address field and you can use CSS like this (note that the Address field in my example has the id, 6)

label[for="Field6_DSG5"] { display:none; }

along with the javascript from above.

0 0
replied on April 15, 2016

Alexander, it's still saving the Country title to Laserfiche. It's not showing when we fill out the form.

0 0
replied on April 15, 2016

Can you confirm that you're using the correct field id? Also, what version of Forms are you using? When I do this in Forms 10, it works fine for me. See the screenshots below.

0 0
replied on April 15, 2016 Show version history

I started a brand new test just to try it out. It's the only field. We have Version 9.2

 

$(document).ready (function () {
  $(".Country").parent().children().css('display', 'none');
})
label[for="Field1_DSG5"] { display:none; }

 

0 0
replied on April 15, 2016 Show version history

Because you're using Forms 9.2, you can use this javascript by itself without the additional CSS

$(document).ready (function () {
  $(".Country").parent().children().css('display', 'none');
  $("#Field1_DSG5").siblings().css('display', 'none');
})

Forms 10 has the "for" attribute in label elements but Forms 9.2 doesn't so you can instead target the sibling elements of "Country" which includes its label and hide that.

 

1 0
replied on April 15, 2016

That works perfectly! 

0 0

Replies

replied on May 15, 2015

How would I add this code if I already was using js on some other areas of the form?

0 0
replied on May 15, 2015

If you already have Javascript running on the form, all you need to do is add

$(".Country").parent().children().css('display', 'none');

inside your existing $(document).ready()

For example, going back to your other question about setting a fixed range for a date field, let's say you then want to add an address field to that same form and you want to hide the country field. Your Javascript would just look something like

$(document).ready(function () {
  var minDate = ("2013-07-01");
  var maxDate = ("2014-05-30");
  $('.fixedrange input').attr('min',minDate);
  $('.fixedrange input').attr('max',maxDate);

  $(".Country").parent().children().css('display', 'none');
});
1 0
replied on May 18, 2015

Great!  Thank you.

0 0
replied on May 18, 2015

Since the address field is required on our form, we are getting a validation error when we try to submit without filling in the Country field, even though the Country field is hidden.

What can we add to remove this issue?

If, alternatively, it's easier to prepopulate all country fields with "USA" what can we add to do that on form load?

0 0
replied on May 18, 2015

See the resolution from this previous thread.

0 0
replied on July 21, 2020

What it the rule of thumb when you want to hide the Country AND Zip code fields? 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.