Reputation: 55
I'm using the following code to create a simple form. How do I make it so that when someone clicks in one of the input fields, the border changes colour? Thanks in advance
<style>
.texta {
color: #CDCBCB;
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
font-style:italic
}
.sendbutton {
background:#F6F6F6; color:#999999;
border: 1px solid #E2E2E2;
cursor:pointer;
padding:5px 10px;
-webkit-border-radius:8px
}
</style>
<form action="mailto:[email protected]" method="post" enctype="text/plain">
<div style="height:12px;"><input type="text" name="name" value="Name (required)" size="40" class="texta"></div><br>
<div style="height:12px;"><input type="text" name="mail" value="Email (required)" size="40" class="texta"></div><br>
<div style="height:12px;"><input type="text" name="comment" value="Subject (required)" size="40" class="texta"></div><br>
<textarea name="Message" value="Message (required)" cols="40" rows="6" class="texta"></textarea><br>
<br><input type="submit" value=" Send " class="sendbutton">
</form>
Upvotes: 0
Views: 185
Reputation: 409
You can do by jQuery too. Just download jQuery (http://jquery.com/) and put this code in your .... But, I think the CSS solution is better.
<script>
$("input:text")
.focus(function(){
$(this).css("border-color", "#F00");
})
.focusout(function(){
$(this).css("border-color", "#333");
});
</script>
Upvotes: 0