c# - Auto Tooltip Validation in MVC 4? -


where heck these things coming from? them, , leverage them elsewhere in site. appears show when regular expression validation in model:

[display(name = "residential")] [regularexpression(@"[-+]?[0-9]*\.?[0-9]?[0-9]", errormessage = "must number")] public byte? residentialexperience { get; set; } 

enter image description here

<div class="editor-label row">     @html.labelfor(model => model.residentialexperience) </div> <div class="editor-field row">     @html.editorfor(model => model.residentialexperience)     @html.validationmessagefor(model => model.residentialexperience) </div> 

how can use these validation tooltips elsewhere? also, how can turn them off?

also: it's not displaying same message have in model. says, "please enter number" whereas have written "must number."

this because outputting numeric field. if @ html see have this:

<input type="number" ... /> 

by defining type numbber, browser knows expect , give generic message. part of html 5 spec.

if want override default behavior this:

@html.textboxfor(model => model.residentialexperience, new { @type = "text" }) 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -