Help with validate
Help with validate
New to jQuery and I am trying to use the validate plugin. I am wanting to add a method to validate that the startTime and endTime are valid values (i.e. 00:00-24:00) and if a startTime is entered then endTime is required. Any help is greatly appreciated.
Bruce
Sample code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Payment Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/jquery.maskedinput-1.2.2.min.js"></script>
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }
});
$().ready(function() {
$("#startTime").mask("99:99");
$("#endTime").mask("99:99");
// validate input form on keyup and submit
$("#inputForm").validate({
rules: {
processorCode: "required",
},
messages: {
processorcCode: "Please enter processor code",
}
});
});
</script>
</head>
<body>
<form id="inputForm">
<div>
<label for="processorCode">Processor Code *</label>
<input class="required" id="processorCode" name="processorCode" type="text" size="10" maxlength="6" />
</div>
<div>
<label for="startTime">Start Time</label>
<input id="startTime" name="startTime" type="text" value="0700" size="6" />
</div>
<div>
<label for="endTime" id="endtime" class="column2">End Time</label>
<input id="endTime" name="endTime" type="text" value="" size="6" />
</div>
<div>
<input class="submit" type="submit" value="Submit"/>
</div>
</form>
</body>
</html>