Where should validation reside when using ViewModels with MVC (MVVM), on the Model or the ViewModel? (Or both or neither)? And why? I bring this up especially in light of V2 of ASP.NET MVC coming out soon.
What about complex/custom validation?
...
Hello,
I just started using LINQ to SQL classes, and really like how this helps me write readable code.
In the documentation, typical examples state that to do custom validation, you create a partial class as so::
partial class Customer
{
partial void OnCustomerIDChanging(string value)
{
if (value=="BADVALUE") throw new...
I am trying to update the error message for a CustomValidator that uses a ValidatorCallOut via javascript. Basically its checking to see if a number entered is an increment of a specified number. I have some code that will update the error message the first time it is run, but after that it will no longer update the error message, alth...
I have errors in a model that are showing up in the view when accessed with @model.errors. However, they do not show up if I try to do
<%form_for @applicant do |f|%>
<%=f.error_messages%>
This is zero, freakily: <%=f.error_messages.length%>
But this is not: <%[email protected]%>
however, the errors are p...
Hi
I have a validation class that implements IDataErrorInfo that has all the methods that you must implement.
One is
public string this[string columnName]
{
get
{
}
}
return "";
Now in this switch statement I have some validation for my form.
Now I noticed lots of my for...
I am working on windows form based application.
I want to validate textbox values. User enter only Numeric values in the textbox ,
now i am able to validate keypressevent, but i want validate copied value should be numeric then only paste(Mouse right click paste or Ctrl+v) textbox.
...
The codeigniter form validation library provides the option to 'prep' data from a form that is being validated. The following is a snippet from the documentation:
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
The xss_clean parameter at the end supposedly passes t...
I have model classes in Linq-to-Sql with partial classes marked with data annotation attributes and a reference to xVal.
When I bind a view directly to a model everything works great, both the JS generated by xVal and server side double check.
Many of my views don't take input to one specific model, so I am setting up view model cl...
I am trying to make the user input exactly 4 characters with no spaces... here's what I have:
.[^\s]{4}
but everything I enter says that it didn't match the regex...
Where am I going wrong?
...
I have a couple of textboxes that will contain dates only. If one textbox has a date and the user tries to submit without entering a date in the other date textbox they will be stopped before submit. The way I want to do this is with the following javascript function:
function ClientValidate(sender, args) {
// Get Both form field...
Possible Duplicate:
What is the best regular expression for validating email addresses?
I am using this particular regular expression for checking emails.
"^[A-Za-z0-9](([a-zA-Z0-9,=\.!\-#|\$%\^&\*\+/\?_`\{\}~]+)*)@(?:[0-9a-zA-Z-]+\.)+[a-zA-Z]{2,9}$"
The issue I have is that, this allows periods before the "@" symbol.
Is ther...
Hi,
If I apply a style from the SL 3.0 Toolkit to my application the built in SL 3.0 data validation errors are not displayed on the application edit forms. If I removed the code that applies the toolkit style to the application the SL 3.0 data validation errors appear as per normal SL 3.0 behaviour?
Has anyone else come across this pr...
Not even sure if this is the right way to title the question. I know I'm making my AJAX calls all wrong... here's what I'm doing right now (I'm using ASP.NET MVC backend by the way):
I use jQuery.ajax to post some data to an action, which will load a view that I capture in the response. It's basically providing some data to an action, a...
I would like to reduce the following code. The below code works, however it is not very tidy etc.
<label for="Name">Name:</label><%= Html.TextBox("Name")%><%
if (!string.IsNullOrEmpty(Html.ValidationMessage("Name"))) {
string Error = HtmlRemoval.StripTags(Html.ValidationMessage("Name")); %>
<img src="Error.gif" alt...
I am using jQuery validation plugin and I want that the error message to be displayed in a specific text input with id="test".
How do I do this?
...
Hello!
I need a litle help to validate my form:
Now, i use this code to validate my form:
$(document).ready(function() {
$("#set_search").validate({
rules: {
q: {
required: true,
minlength: 2
},
q2: {
number: true
},
},
messages: {
q: "Please enter ...
Can someone point me to a web-/screencast or tutorial--video preferrably--that explains this new namespace and how I can use it to help validate data like user input? Pretty please.
...
How can I test that my controller action is putting the correct errors in the ModelState when validating an entity, when I'm using DataAnnotation validation in MVC 2 Preview 1?
Some code to illustrate. First, the action:
[HttpPost]
public ActionResult Index(BlogPost b)
{
if(ModelState.IsValid)
{
...
I have an Account model and a User model:
class Account < ActiveRecord::Base
has_many :users
end
class User < ActiveRecord::Base
belongs_to :account
end
Users belong to an account and an account have a user maximum (different for each account). But how do I validate that this maximum have not been reached when adding new users to ...
I'm using the jQuery plugin Validation to validate a form. I have a select list looking like this:
<select id="select">
<option value="">Choose an option</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
<option value="option3">Option3</option>
</select>
Now, I want to make sure that the user s...