JQuery include Form Parameter in output

Hello, I have a form that returns an error if the submit action fails.

The form is
<form action="" method="post" name="Register" class="fancyform" id="Register">
  <h3>Register</h3>
    <div class="notify">Please complete the form below and click 'Register'</div>
    <div class="alert" id="RegisterError" style="display:none;"></div><div class="halfbox">
    <label for="regfirstname">First name</label>
    <input name="regfirstname" type="text" required="required" id="regfirstname" form="Register" placeholder="First name" value="" maxlength="50" /><br/>
    </div>
    <div class="halfbox">
    <label for="regfirstname">Last name</label>
    <input name="reglastname" type="text" required="required" id="reglastname" form="Register" placeholder="Last name" maxlength="50" /><br/>
    </div>
    <div class="halfbox">
    <label for="regfirstname">Email</label>
    <input name="regemailaddress" type="email" required="required" id="regemailaddress" form="Register" placeholder="e.g joe.bloggs@yahoo.co.uk" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" maxlength="135" /><br/>
    </div>
    <div class="halfbox">
    <label for="regfirstname">Password</label>
    <input name="regpassword" type="password" required="required" id="regpassword" form="Register" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" maxlength="50" /><br/>
    </div>
    <div class="labeldiv">
      <label title="Tick this option to have this computer / device store your login credentials">
                                                <input type="checkbox" name="rememberme" value="true" checked="checked">
                                                Remember me
      </label>
    </div>
    <input name="Register" type="submit" disabled="disabled" id="RegisterSubmit" form="Register" value="Register" />
  <input name="Cancel" type="button" class="cancelbutton closefb" id="RegisterCancel" onclick="$.fancybox.close()" value="Cancel" form="Register" />
  <input type="hidden" name="returnUrl3" value="">
</form>

Open in new window


The JQuery is

  $("#Register").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/register.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
     		 $.fancybox.close();
			 location.reload();
          }else {
            // do something fail
	      $('#RegisterError').html('<p>An account already exists with the username XXXXX. Please either <a class="fancybox" href="#SignIn" rel="nofollow">Login</a> or <a class="fancybox" href="#PasswordRequestfrm" rel="nofollow">Reset your password</a></p>');
          $('#RegisterError').fadeIn('slow');
          }
  	  }});
  });

Open in new window


I want the section

$('#RegisterError').html('<p>An account already exists with the username XXXXX. Please

to replace the XXXXX with the form parameter value regemailaddress

Is this possible?

Thanks
garethtnashAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
This should do it.
...
var email = $('#regemailaddress').val();
$('#RegisterError').html('<p>An account already exists with the username ' + email + '. Please either <a class="fancybox" href="#SignIn" rel="nofollow">Login</a> or <a class="fancybox" href="#PasswordRequestfrm" rel="nofollow">Reset your password</a></p>');
...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Great - thank you
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.