Radiobutton Validation in jQuery
This validation works, but the error message is shown next to the radiobutton moving the before the default label for the radiobutton. Is there a way of putting the error message align to the right instead?
Run the code to see what I mean.
Thanks for your assistance.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Validation Demo</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#form1").validate({
rules: {
accept: "required",// simple rule, converted to {required:true}
},
messages: {
accept: "* Required",
}
});
});
</script>
<style type="text/css">
label.error {
color: red;
}
</style>
</head>
<body>
<form id="fo开发者_如何学运维rm1" method="post" action="">
<div>
<input type="radio" name="accept" value="accept" /> Accept
</div>
<input class="submit" type="submit" value="Submit">
</form>
</BODY>
</html>
You can try this:
label.error {
color: red;
position:absolute;
left:75px;
}
Working Example: http://jsfiddle.net/jasongennaro/Ja8jr/
精彩评论