Hopefully someone can help, I have been going crazy trying to figure this out. I am working on an MVC 5 application. I created a form and table in my viewmodel. Below are the 2 text box inputs I am working with. Jquery Validation is putting a validation rule on markup input box for step=.10 even though I don't specifically set the rule and this rule is not working. The text box gives an error for many inputs including (1.1, 1.2, 1.3, however input 1.6 passes.) The error is "Please specify a multiple of 0.1" The other wierd thing is, this works fine if a run from localhost debugging, however when I publish to hosted server, it does not work at all. The soldbox step of 10 works fine, there is no validation on it.
Any ideas??
Ian
@Html.TextBox("markup" + @item.ID, (item.markup == 0 ? new decimal(1.0) : item.markup), new { data_id = item.ID, style = "width:75px", @class = "markupbox form-control", @type = "number", @min = 0, @step = .10 })
@Html.TextBox("sold" + @item.ID, new decimal(0), new { data_id = item.ID, style = "width:75px", @class = "soldbox form-control", @type = "number", @min = 0, @max = 100, @step = 10 })
//JAVA SNIPPET
$('#livecartitems').validate({
errorClass: "text-danger"
});
$('.soldbox').each(function () {
$(this).rules('add', {
min: 0,
max: 100,
messages: {
min: "must be >= 0",
max: "must be <= 100"
}
})
$(this).rules('remove', 'step');
});
});
//EDITTED JAVASCRIPT - Still does not work
$('#livecartitems').validate({
errorClass: "text-danger"
});
$('.markupbox').rules('remove', 'step');
I just tried a very simple example... Same behavior. 1.5 doesnt work, but 1.6 passes. Very strange. I am next going to try to reload the JS files or point them to google hosted JS scripts.
<form id="testform">
@Html.TextBox("markup", new decimal(1.0), new { @style = "width:75px", @class = "markupbox form-control", @type = "number", @min = 0, @step = .10 })
</form>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<script type="text/javascript">
$('#testform').validate({
errorClass: "text-danger"
});
</script>