JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<form id="subscribeform" name="subscribeform" action="mailform.php" method="post">
<div id="mailform">
<div id="desc">Stay informed with the latest news from the Foundation: </div>
<input type="text" id="email" name="email" placeholder="Enter email address" value="Enter email address"/>
<input type="image" src="http://www.bonemarrow.org/images/sendbutton.jpg" id="sendbutton" name="sendbutton" />
</div>
</form>
CSS
div.error {
font-size: 10px;
width: 288px;
text-align: center;
display: inline;
float: left;
position: fixed;
z-index: 1;
padding: 2px;
margin-left: 6px;
background-color: #fcd6cf;
border: 1px solid #bb1124;
display: none;
}
JavaScript
$.fn.search = function() {
return this.focus(function() {
if (this.value == this.defaultValue) {
this.value = "";
}
}).blur(function() {
if (!this.value.length) {
this.value = this.defaultValue;
}
});
};
$("#email").search();
$("#subscribeform").validate({
errorElement: "div",
errorPlacement: function(error, element) {
error.insertBefore($("#desc"));
},
rules: {
email: {
email: true
},
},
messages: {
name: "Please specify your name",
email: {
email: "Please enter a valid email address."
}
}
});