Passing username portion of email address to hidden field
I'm trying to pass just the username portion of an email address to a hidden field. Here's what I got so far:
- jQuery(document).ready(function(){
- jQuery("form").bind('submit',function(e){
- e.preventDefault();
- var formEmail=jQuery("input[name=email]").val();
- jQuery("input[type=hidden][name=hidden_email]").val(formEmail);
- alert(jQuery("input[type=hidden][name=hidden_email]").val());
- alert(formEmail);
- });
- });
- <form method="post" action="#">
- <input type="text" id="email" name="email"/>
- <input type="hidden" id="hidden_email" name="hidden_email"/>
- <input type="submit" id="submit" class="button" value="Submit" />
- </form>