The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
javascript username extract from email address
Hello,
I need to extract the part before @ from email address.
For example:
Field-1 (e-mail): [email protected]
Field-2 (copy from the e-mail): example
I used the following code;
<script type="text/javascript">
jQuery(document).ready(function($){
$('#field_source').change(function(){ //source field key
var sourceField = $("#field_source").val(); //source field key
$("#field_dest").val(sourceField); //destination field key
$("#field_dest").change(); //destination field key
});
});
</script>
But, it copies whole e-mail address.
So, i would like to add the following code the work it.
var name = email.substring(0, email.indexOf("@"));
How to make the complete code?
Please help.
Thanks.
February 8, 2018 at 6:38 am
https://jsfiddle.net/1hdvx1y8/3/
I'm using the focusout method, such that function doesn't execute until you leave the input box.
February 13, 2018 at 11:21 am
GREAT~ Thanks.
Discussion closed.