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) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • how to make a custom field must to start from 8 and 9
Pages: [1]

Author Topic: how to make a custom field must to start from 8 and 9  (Read 786 times)

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
how to make a custom field must to start from 8 and 9
November 26, 2014, 08:02:57 pm
 hi all,

is it possible , to set custom field must to start 8 and 9

the case is the field will gather contact number

thanks in advance

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: how to make a custom field must to start from 8 and 9
November 26, 2014, 11:54:44 pm
I have no idea what you are asking  ;D
Quote
is it possible , to set custom field must to start 8 and 9
Do you mean there has to be a default start value for a custom field?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

joanne

  • Administrator
  • Ask me questions
  • *****
  • Posts: 852
  • Karma: 83
  • CiviCRM version: 4.4.16
  • CMS version: Drupal 7
Re: how to make a custom field must to start from 8 and 9
November 27, 2014, 04:27:34 am
Do you mean that any contact number that is entered will be either 9XXXX... or 8XXXX...?

Do you want an error message to be shown if someone enters say 7654... in the custom field?

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
Re: how to make a custom field must to start from 8 and 9
November 27, 2014, 08:39:13 pm
Thanks a lot Joane and Erick Hommel
 You are right

i mean like that,

exactly like you mean , Joanne

is it possible in civicrm ?

thanks for help

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: how to make a custom field must to start from 8 and 9
November 28, 2014, 10:45:54 am
I believe that this sort of customization usually requires some programming.

The general formula is (1) figure out which screens need the custom behavior, (2) write some Javascript to implement the behavior, and (3) inject the Javascript code on each screen. There's some examples on this topic:

http://www.jackrabbithanna.com/articles/easy-jquery-modificaiton-civicrm-forms
https://civicrm.org/blogs/dave-greenberg/now-its-easier-add-custom-behaviors-templates
http://forum.civicrm.org/index.php/topic,32968.msg140501.html#msg140501

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
Re: how to make a custom field must to start from 8 and 9
November 30, 2014, 07:34:26 pm
Thanks a lot Totten
learning it  ::)

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
Re: how to make a custom field must to start from 8 and 9
December 01, 2014, 11:27:42 pm
it is too difficult to learn by me in quick time

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: how to make a custom field must to start from 8 and 9
December 02, 2014, 02:25:33 am
There's also http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm which I suspect might come in handy (for others that stumble across this post).
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
Re: how to make a custom field must to start from 8 and 9
December 03, 2014, 12:47:35 am
Thanks a lot Michael , very helpfull ,
but just litle more ,

for addres code ( highlights ) , how do i determines that , because for my case is the field on custom data.

function MYMODULE_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ) {
  if ($formName == 'CRM_Contact_Form_Contact') {
    foreach ($fields['address'] as $key => $address) {
     
« Last Edit: December 03, 2014, 12:52:51 am by henro »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • how to make a custom field must to start from 8 and 9

This forum was archived on 2017-11-26.