CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Add asterisk to required fields in contribute form
Pages: [1]

Author Topic: Add asterisk to required fields in contribute form  (Read 484 times)

lee

  • I’m new here
  • *
  • Posts: 24
  • Karma: 0
  • CiviCRM version: 4.2.16
  • CMS version: wordpress 3.8.1
  • MySQL version: 5.6.14
  • PHP version: 5.4.4.
Add asterisk to required fields in contribute form
May 05, 2014, 03:14:23 pm
Is there a way to add asterisk to required fields in contribute form. The user should see the asterisk next to the field. I know when they click submit it comes up but it would be good to have on each field that is required. I read somewhere that it has something to do with paypal option but I'm not using that, so I would like those asterisks added on those fields. Appreciate any help.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Add asterisk to required fields in contribute form
May 05, 2014, 03:25:55 pm

you should be able to do this via a jQuery / js snippet on the contribution page.

Please do share your code when done

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lee

  • I’m new here
  • *
  • Posts: 24
  • Karma: 0
  • CiviCRM version: 4.2.16
  • CMS version: wordpress 3.8.1
  • MySQL version: 5.6.14
  • PHP version: 5.4.4.
Re: Add asterisk to required fields in contribute form
May 12, 2014, 10:35:45 am
You would think something like this would work, but 'this' isn't recognized. Nothing below the billing block seems to be accessible. I've tried the various elements and ids below the block level and I get nothing. Any ideas?

$('#billing-payment-block > label').each(function(){
  $(this).wrap('<span class="crm-marker">*</span>');
  // alert($(this));
});

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Add asterisk to required fields in contribute form
May 12, 2014, 02:34:23 pm
From the looks of your code you're referring to the billing block fields.

As of CiviCRM 4.4 all billing block fields that are required already do have a * next to them. 

http://drupal.demo.civicrm.org/civicrm/contribute/transact?id=1

If you are not referring to these billing fields, you set the * by making it a required field in the profile.

If not 4.4, try this code with cj or wrap it in an "onReady".
Code: [Select]
cj('#billing-payment-block > label').each(function()
« Last Edit: May 12, 2014, 02:35:57 pm by CiviTeacher.com »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Add asterisk to required fields in contribute form

This forum was archived on 2017-11-26.