Community I request your collaboration since I have a texboxfor in which only numbers must be accepted, However, I have already developed a javascript function for this field and I don't know how to insert a new function or modify the code to validate only numbers. I appreciate any help to solve this problem.
HTML:
@Html.TextBoxFor(model => model.Zipcode1, new { style = "width: 800px; text-transform:uppercase", @class = "form-control col-4", onchange = "validaZipcode(this.value)" })
JavaScript:
function validaZipcode(Zipcode1) { $.ajax({ url: "/ValidateAddress/ValidateZipcode", type: "POST", dataType: "Json", data: { Prefix: Zipcode1 }, success: function (data) { $.each(data, function (key, d) { $("#Zipcode1").val(d.ozip); $("#Zipcode1").text(d.ozip); $("#City").val(d.o_City); $("#City").text(d.o_City); $("#State").val(d.o_STATE); $("#State").text(d.o_STATE); $("#Street").val(d.address); $("#Street").text(d.address); }) } }) $("#Street").prop('disabled', false); $("#City").prop('disabled', false); $("#Urban").prop('disabled', false); $("#State").prop('disabled', false); }