Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Adding a domain after a name field on a registration form

I am trying to add a domain after a name field and not having success. name field @domain.com

$doc = JFactory::getDocument();
$js = "
jQuery(document).ready(function($){
    // Define the variables
    var regForm     = $('#member-registration');
    var name        = regForm.find('#jform_name'); @domain.com<<<
    var password    = regForm.find('#jform_password1');
    var password2   = regForm.find('#jform_password2');
    var email       = regForm.find('#jform_email1');
    var email2      = regForm.find('#jform_email2');
    regForm.find('.spacer').parents('.control-group').hide();
    regForm.find('.star').hide();
    email.parents('.control-group').hide();
    password2.parents('.control-group').hide();
    email2.parents('.control-group').hide();  
    password.on('keyup', function() {
        password2.val( this.value );
    });
    name.on('keyup', function() {
        email.val( this.value );
    });
    email.on('keyup', function() {
        email2.val( this.value );
    });
    });    
";    
$doc->addScriptDeclaration($js);

Adding the domain would then allow the registration to pass the email stage and generate a email. I don't want to require a user to register with a email since I myself am a email provider.

 name.on('keyup', function() {
        email.val( this.value );
    });

thanks for any advice.. been at it for a couple days now.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hello thank you for your question

Try below code to get exact domain

$(document).ready(function(){
  var domain = window.location.hostname;
  if(domain.indexOf('www.') >= 0)
  {
    domain = domain.replace('www.', '');
  }       
  domain = "@"+domain;

  $("#name").on('keyup', function() {
    var inputVal = $(this).val();
    if($(this).val().indexOf(domain) >= 0)
    {
      inputVal = inputVal.split(domain);
      inputVal = inputVal[0];
    }
    $(this).val(inputVal+domain)
    setCaretToPos(document.getElementById("name"), inputVal.length);
  });
  $( "#name" ).keypress(function(e) {
    var key = e.keyCode;
    if (key >= 48 && key <= 57 || key == 32) {
      e.preventDefault();
    }
  });

  function setSelectionRange(input, selectionStart, selectionEnd) {
    if (input.setSelectionRange) {
      input.focus();
      input.setSelectionRange(selectionStart, selectionEnd);
    }
    else if (input.createTextRange) {
      var range = input.createTextRange();
      range.collapse(true);
      range.moveEnd('character', selectionEnd);
      range.moveStart('character', selectionStart);
      range.select();
    }
  }

  function setCaretToPos (input, pos) {
    setSelectionRange(input, pos, pos);
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>Name -</p>
<input type="text" placeholder="Enter name" id="name" />

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!