jquery - ValidationFor do the validation before I write at the field -


i have following code in model:

[required(errormessage = "the filed required.")] [display(name = "number: ")] public string num { get; set; } 

view:

 <div class="col-lg-4">             <%: html.labelfor(model => model.num) %>             <%: html.textboxfor(model => model.num, new {  @class = " form-control"}) %>             <%: html.validationmessagefor(model => model.num,null , new { @class="text-danger"}) %>         </div> 

controller:

 public actionresult create(sinco model)     {         combo();          populateitemchoices(model);         return view(model);     } 

when enter page, before write data @ fields, message (the field required) appears.

there pages in site don't happen (it validation when write @ filed), can't understand wrong...

thanks in advance.

update: realized happens in pages i'm using following jquery event, still dont know why causing error:

$(document).ready(function () {            $('#idmun').change(function () {                $.ajax({                    url: 'myfunction',                    type: 'post',                    data: { id: $(this).val() },                    datatype: 'json',                    success: function (data) {                        var options = '';                        for(var in data){                            options += '<option value="' + data[i].idlo + '">' + data[i].namelo + '</option>';                        }                        $('#idlo').prop('disabled', false).html(options);                    }                });            });        }); 

hi in opinion you're calling:

public actionresult create(sinco model)

this invoke model binding, try this: public actionresult create() o detect if works attend. how call create method?


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -