<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Adding Validation to the Model</title><link>http://www.asp.net</link><pubDate>Wed, 08 May 2013 16:53:01 GMT</pubDate><generator>umbraco</generator><description>Comments for Adding Validation to the Model</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/37160" rel="self" type="application/rss+xml" /><item><title>Comment Posted by bertvanp</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Mon, 08 Oct 2012 11:28:59 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016590</guid><description><![CDATA[ <p>Small correction to the piece of code on globalization:</p><p></p><p>var val = $.global.parseFloat(value);</p><p></p><p>should be</p><p></p><p>var val = Globalize.parseFloat(value);</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/bertvanp.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by vinaykasireddyasp</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Sun, 09 Dec 2012 22:56:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016971</guid><description><![CDATA[ <p>Hi Rick,</p><p></p><p>You said that validation rules can be added in the Model classes and they will be activated whenever the Model is updated or created wherever necessary. But Can i configure the model class to enforce validation rules only certain times and not all the times based on some conditions. If so, how can we configure these things.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/vinaykasireddyasp.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by javiglc</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Sun, 30 Dec 2012 20:40:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000017090</guid><description><![CDATA[ <p>Reviewing the code for view Create.cshtml, under the heading level 2 Create, there are two javascript tags that were not created in my test mvc4 website (VS2010 Web Developer Express). Are they required in the view? Would it be possible to have this explained with more detail in relation to what it does?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/javiglc.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by vramona</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Wed, 16 Jan 2013 11:53:45 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018181</guid><description><![CDATA[ <p>Thanks Rick for this tutorial</p><p></p><p>I still have an issue. I&#39;m french so I appreciated the dot vs comma distinction using Globalize fwk.</p><p></p><p>With [DataType(DataType.Date)] attribute within the ReleaseDate property of Movie model, it works fine with IE, but not at all with Chrome, it looks like I need to use yyyy-mm-dd format, but I want the same format dd/mm/yyy for both Index and Edit pages and for both IE and Chrome browsers.</p><p></p><p>Any idea for this ?</p><p></p><p>Regards</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/vramona.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ricka6</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Wed, 16 Jan 2013 21:29:35 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018190</guid><description><![CDATA[ <p>@vinaykasireddyasp configure the model class to enforce validation rules only certain times</p><p>Generally no. See <a rel="nofollow" href="http://msdn.microsoft.com/en-us/magazine/hh781022.aspx" target="_blank">msdn.microsoft.com/</a></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ricka6.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by skillfulweb</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Tue, 29 Jan 2013 11:40:03 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018276</guid><description><![CDATA[ <p>@vramona, I too am having problems with the date field in Chrome (en-US locale.)  The bug occurs even with Javascript disabled so this isn&#39;t coming from jQuery.  </p><p></p><p>This article [<a rel="nofollow" href="http://updates.html5rocks.com/2012/08/Quick-FAQs-on-input-type-date-in-Google-Chrome" target="_blank">updates.html5rocks.com/</a>] by Kent Tamura (a Chrome software engineer) says the value attribute of a date field should be assigned as yyyy-mm-dd regardless of locale.  Using VS2012 Express the value is being rendered as mm/dd/yyyy (en-US)</p><p></p><p>Is there a work-around?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/skillfulweb.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by JoeBenet</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Wed, 06 Feb 2013 04:33:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018353</guid><description><![CDATA[ <p>Took me some time to realize that you have missed adjusting the validation for price range manually:</p><p> [Range(1, 100, ErrorMessage=&quot;Price must be between $1 and $100&quot;)]</p><p></p><p>Instead i&#39;ve been trying to find out why I don&#39;t get the price range error along with the $ currency in the digits end.</p><p></p><p>You might want to fix that in the tutorial, And thank you very much for the whole project.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/JoeBenet.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by JoeBenet</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Wed, 06 Feb 2013 08:26:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018355</guid><description><![CDATA[ <p>More problems:</p><p></p><p>If you load the page in chrome you will get forced datepicker that won&#39;t load edited date values etc.</p><p></p><p>When you enter invalid date like 1/1/1350 it will still pass the validation check and an out-of-range error will be thrown.</p><p></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/JoeBenet.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by salman_sulaiman_1979</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Fri, 08 Feb 2013 13:49:03 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018386</guid><description><![CDATA[ <p>Thanks once again Rick!</p><p>simply amazing! I really am so excited about these new cocepts, they are totally new to me, the DRY, and having validations taken care of by simply working it out in one place such as the Class Movie (the Model). </p><p></p><p>When I reached the part where you were explaing the string validation for the date  and currency, I immediatly started thinking of regular expressions, now I see that we can as well benifit from the regular expressions (those have been very important to me validating prerior to form postback), of course that is in the case the scripts not disabled in the browser! (Thanks for the snapshots Rick, good to know that I could disable those scripts. :-)</p><p></p><p>Thanks once again &amp; good luck to all the folks!</p><p>~Salman~</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/salman_sulaiman_1979.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by salman_sulaiman_1979</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Fri, 08 Feb 2013 14:00:29 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018387</guid><description><![CDATA[ <p>@jeff.brown</p><p>Hi Jeff, I had similar error too, but then I realized that I forgot to specify values for the &quot;Rating&quot; in the Seed method in my Configuration.cs, and since I added the &quot;[Required]&quot; attribute for my &quot;rating&quot; field in my Movie Class, then this gets reflected in my Data Table having the column &quot;Rating&quot; Not Null (so it has to have a value). </p><p>so what I did, is closed the connection (from Database Explorer), then Deleted the localDB, then went back to the Solution Explorer and Deleted the mdf file from the App_Data, rebuild everything, (of course prior to all that, I updated my Configuration.cs so that my &quot;Rating&quot; field has a value), after all that, I executed the &quot;update-database&quot; from the library package console! Plus all that, I applied the updates in both the Create, and Edit Views so to include the &quot;Rating&quot; label and editor fields. </p><p>right, I hope I haven&#39;t missed anything. But that what i did, Jeff, Give it a try. </p><p>Thanks again folks and Rick!</p><p>~Salman~</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/salman_sulaiman_1979.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by salman_sulaiman_1979</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Fri, 08 Feb 2013 14:08:13 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018388</guid><description><![CDATA[ <p>@JoeBenet </p><p>Hi Joe!</p><p>Yes, I just tried what you were pinpointing and very true, I didn&#39;t know that, waw! so Chrome renders the page differently than Internet Explorer 9 does. Very interesting to know. Thanks Joe!</p><p>so this is another issue I need to look at when developing an application with client side scripting involved, got to make sure it works in chrom too! </p><p>thanks joe and everyone!</p><p>~Salman~</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/salman_sulaiman_1979.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ilevin350</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Thu, 21 Feb 2013 19:29:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018493</guid><description><![CDATA[ <p>I ran into an issue when I tried to add a date range validation to the Movie class:</p><p></p><p>[Range(typeof(DateTime), &quot;1/1/2010&quot;, &quot;1/1/2020&quot;)]</p><p>public DateTime ReleaseDate{ get; set; }</p><p></p><p>It turns out that the client side validation using jQuery always fails with a message saying the date must be between &quot;1/1/2010&quot; and &quot;1/1/2020&quot;, no matter what I type into the date field, while the server side validation always works (passes if I pass in a valid date string, otherwise fails).  Do you see this behavior?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ilevin350.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Acecx</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Sat, 02 Mar 2013 08:35:48 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018560</guid><description><![CDATA[ <p>The [DataType(DataType.Date)] of verification in lastest Version,when you edit content(Edit.cshtml),The already date data will not be displayed to the date picker.</p><p>How to solve it?Thanks!</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Acecx.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by aloshin</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Mon, 04 Mar 2013 17:06:09 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018572</guid><description><![CDATA[ <p>Thanks a lot Rick for this toturial. I tried it and everything worked fine; the only problem I see is the validation message for the &quot;Price&quot; when I am creating or editing a movie record, the validation message shows exactly as &quot;Price must be between 1 to 100&quot; - it doesn&#39;t have any &quot;$&quot; in the message. Is there anything that I am missing? </p><p>Is there anybody having the same problem?</p><p>Thank you all.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/aloshin.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Danny117</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Thu, 07 Mar 2013 16:09:00 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018607</guid><description><![CDATA[ <p>I&#39;ve made it this far.  Turned off javascript and still had a working page.  Once again I wanted to see cluture done with a bundle.  I have to remember.  Next time I do a code first migration I want to have the verbose flag on so I can see what&#39;s going on.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Danny117.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by payini</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Mon, 11 Mar 2013 16:52:55 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018651</guid><description><![CDATA[ <p>Great tutorials. Thank you.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/payini.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by _Mango</title><link>http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model</link><pubDate>Wed, 08 May 2013 16:53:01 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000019073</guid><description><![CDATA[ <p>EDIT SPELLING* on Adding Validation to the Model </p><p>You have =&gt;&quot;We will us migrations to update the scheam.&quot;</p><p></p><p>Should be =&gt; &quot;We will use migrations to update the schema.&quot;</p><p></p><p>Great tutorial btw.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/_Mango.jpg?forceidenticon=false&amp;dt=635071855800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>