Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda