I am trying to setup a form using jQuery click method. For html I don't want to use onClick but rather call from the id clickMe to display name. It doesn't seem to be working. Is this possible? if so, What am I missing?
var getName = function ()
{
if (document.getElementById("FirstName").value == "" || document.getElementById("LastName").value == "")
{
return ("Please enter your first name and last name.");
}
else {var fullName = document.getElementById("FirstName").value + ' ' + document.getElementById("LastName").value;
return fullName;
}
}
var displayName = function ()
{
$(document).ready(function(){
$("#clickMe").click(function(){
alert(displayName());
});
}); //end ready
}
HTML
<form name="form" id="form" method="post" action="">
<p class="FirstName">
<label for="FirstName">First Name:</label>
</p>
<p>
<input name="FirstName" type="text" id="FirstName" />
</p>
<p class="LastName">
<label for="LastName">Last Name:</label></p>
<p>
<input name="LastName" type="text" id="LastName" />
</p>
<p class="submit">
<input name="submitButton" type="button" id="clickMe" value="Display Name" />
</p>
</form>