asp.net mvc 3 - How do I client validate a razor view with input tags -


i new mvc. there way client validate razor view having general inputs

<input type-"text" id="txtfirstname" /> 

i have seen there ways using dataannotation attribute in model , @html.textbox or @html.textboxfor. not find can validate pure html form element. using html.beginform render form on page.

you want validation on text box without using razor.you can come jquery validation.(rules , message.)

$(document).ready(function () {

$("#account_info").validate({     rules: {         phone_number: {             required: true         },         recipient_name: {             required: true,             minlength: 6  // <-- removed underscore         }     },     messages: {         phone_number: {             required: "this field required"         },         recipient_name: {             required: "enter recipient name",             minlength: "name should @ least {0} characters long" // <-- removed underscore         }     },     submithandler: function (form) { // demo         alert('valid form');  // demo         return false;  // demo     } }); 

});


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -