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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Fixing autofill for URL field on Drupal user registration when profile used
Pages: [1]

Author Topic: Fixing autofill for URL field on Drupal user registration when profile used  (Read 1982 times)

greenmachine

  • I post occasionally
  • **
  • Posts: 58
  • Karma: 6
Fixing autofill for URL field on Drupal user registration when profile used
October 27, 2008, 12:18:21 pm
I have a client running CiviCRM 2.0 and Drupal 5. They want the URL (Home URL) field available on the user registration form through a CiviCRM profile. However, they don't like the little bit of javascript that autofills "http://" when the user clicks on the element or tabs through it (onfocus). They have experienced some users complaining about getting the "enter a valid URL" error just because they accidentally clicked or tabbed on the field - even though the user did not intend to enter a URL at all.

Dunno if the behavior is the same in 2.1 or not, but here's a bit of Drupal module code with jquery script that will "fix" the accidental onfocus behavior:

Code: [Select]
function yourmodulename_form_alter($form_id, &$form) {
  if ($form_id == 'user_register') {
    $js = '$(function(){
      $("#edit-submit").click(function () {
        var homeURL = $("#home_URL").val();
        if (homeURL == "http://") {
          $("#home_URL").val("");
        }
      })
    });';
    drupal_add_js($js, 'inline');
  }
}

Yeah, kind of hacky, but seemed like a reasonable quickfix to a non-critical issue.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Fixing autofill for URL field on Drupal user registration when profile used
October 28, 2008, 06:50:03 pm
Thx for the suggestion. The problem has been fixed in 2.1 - the 'http://' appears when you tab into the field and disappears when you tab out (onblur) if you don't add anything / change the value.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Fixing autofill for URL field on Drupal user registration when profile used

This forum was archived on 2017-11-26.