Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

The client side html attribute table of Unobtrusive js in ASP.NET MVC3.
jifeng
#1 Posted : Monday, August 29, 2011 3:26:59 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
Required data-val-required = "The field is required."

Remote data-val-remote-url = "/Account/LogOn"
data-val-remote-additionalfields = "*.UserName"
data-val-remote = "The error message."

RegularExpression data-val-regex-pattern = "(\d-)?(\d{3}-)?\d{3}-\d{4}"
data-val-regex = "The error message."

Range data-val-range-min = "-5"
data-val-range-max = "7"
data-val-range = "The error message."

StringLength data-val-length-max = "100"
data-val-length ="The error message."

Compare data-val-equalto-other = "*.NewPassword"
data-val-equalto = "The error message."
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
ifumust
#2 Posted : Thursday, September 01, 2011 10:49:47 AM(UTC)
Rank: Member
Groups: Registered

Joined: 6/24/2011(UTC)
Posts: 14
how do i get this validation to work? Do i need to add any javascript code? do you have more info
Baseless
#3 Posted : Thursday, September 01, 2011 12:40:13 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 6/10/2010(UTC)
Posts: 141
Location: Sweden
Havent tried it but if it works as standard it should be enough to include implementations of the examples above in the elements to be validated. Though would be nice if this where automated via a html helper or something.
jifeng
#4 Posted : Friday, September 02, 2011 1:19:42 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
1. The site must include the JQuery scripts.

2. Add the validation attributes into the html tags.

jifeng attached the following image(s):
Capture1.PNG (36kb) downloaded 29 time(s).
Validation.PNG (56kb) downloaded 34 time(s).

You cannot view/download attachments. Try to login or register.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
ella
#5 Posted : Thursday, March 15, 2012 9:24:20 AM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 56
Location: Russia
I try to use RegularExpression validation in e-mail field. I write some code in view like this:
Code:
<tr>
  <th><label for="from">From email:</label></th>
  <td>
     <input type="text" id="from" name="From" 
     data-val-required="From is required" data-val="true" 
     data-val-regex-pattern = "\b[a-zA-Z0-9._%\-+']+@[a-zA-Z0-9._\-]+\.[a-zA-Z]{2,6}\b"
     data-val-regex = "Not valid e-mail." />
     @Html.ValidationMessageForInput("From")
   </td>
</tr>

But when view renders, I get this error:
Quote:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: "[" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.


'"[" is not valid' - but how can I create RegExp without this symbol?
jifeng
#6 Posted : Thursday, March 15, 2012 9:32:13 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
Replace "@" with "@@", it is the keyword of Razor...
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
1 user thanked jifeng for this useful post.
ella on 3/15/2012(UTC)
ella
#7 Posted : Thursday, March 15, 2012 10:04:13 AM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 56
Location: Russia
Oh, yes, I'm so stupid. Thanks.
jifeng
#8 Posted : Tuesday, March 20, 2012 11:44:48 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
Waiting for MVC4 and WebPages2, we will get some useful features from it, especially: http://www.asp.net/web-p...n-web-pages-2#validation
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.089 seconds.