181 questions
0
votes
1
answer
41
views
Why doesn't ASP.Net MVC client side validation trigger where input is outside form element, but linked via form="formid" attribute?
I am using ASP.Net 8.0 MVC...
ScenarioName property has a Required attribute in the Model..
When I use the following, clicking submit button with all of these elements wrapped inside the form tag ...
0
votes
1
answer
45
views
MVC disabling client side validation on a model field
I have a model for creating/editing items and the items can belong to a category.
The category renders as a drop down so the user can choose a category, or fill in a new category via a textbox.
The ...
0
votes
1
answer
140
views
MVC Core Validation - render as valid initially
I have an MVC 5 web app, and an MVC Core web app, and I am using unobtrusive validation in both.
When you use TextBoxFor and ValidationMessageFor for a required property, the 2 apps behave ...
0
votes
1
answer
85
views
c# mvc how to validate 3rd column Value Based on Two column
Here I have three properties Like
Public Class Addition{
public Int Val1{get;se;}
public Int Val2{get;se;}
public Int Val3{get;se;}
}
In .cshtml Val1=10;Val2=20; If User Entre Val3=30 Then How can i ...
0
votes
2
answers
625
views
Jquery email validation is not working in MVC
I'm using this code in mvc for email validation but after we typed @ of any text in textbox for example : abc@ after @ validation is not wokring and form is submit without validation error.
if (!...
0
votes
1
answer
671
views
ASP.NET MVC Html Helper: Adding a validation in an enum ddl
I'm pretty new in ASP.NET MVC. And I'm very sorry for this question.
What my goal is: To add a validation using Html Helper of ASP.NET MVC on an enum ddl.
Model
public enum SampleEnum {
Active ...
0
votes
1
answer
103
views
mvc validationMessage is not working while its in IEnumerable<T>
I have a class :
public class Cust
{
[Required(ErrorMessage ="NameField Req")]
public string Name { get; set; }
}
I use this class :
public class CustModel
{
public IEnumerable<Cust&...
0
votes
0
answers
503
views
Model object is not validated if a member is invalid
I'm writing an ASP.NET Core web app. I'm using MVC's model validation framework, and I have a "form" model that contains a Product object and a IsCreationMode boolean.
I want to validate the Product,...
2
votes
0
answers
77
views
ASP.NET MVC validation message does not display error message [duplicate]
I have looked at my code and endless examples and looked at other questions as well, but nothing I try works for me.
I am trying to validate my view. The field border is red on submit but the error ...
0
votes
1
answer
2k
views
Required field validator for a textbox in MVC depend on a dynamically generated drop down list
I'm generating some controls with the help of a for-each loop. I would like to validate the textbox depend on the answer of the dropdown. For some questions, validator should be enabled if the ...
5
votes
0
answers
185
views
Cross-site scripting (XSS) patterns can be submitted
Cross-site scripting (XSS) patterns can be submitted.
[HttpPost]
[AllowAnonymous]
[ValidateInput(false)]
public async Task<string> Index(string Xml) => await Process(Xml);
If i remove ...
-1
votes
1
answer
128
views
Radio button validation before post
I want to ensure that a user picks an answer to the question being asked. I have tried JQuery, Custom Validation class, setting model attributes to required. To summarise, if no radio button is ...
1
vote
1
answer
651
views
ModelState.AddModelError - How can I makeup the Resource error string
I have a ASP.NET MVC5 project where I do some input validation over more then 1 field.
When an error is found I add an error to the model via :
ModelState.AddModelError("field", Resource.ErrorMessage)...
0
votes
0
answers
239
views
How to validate input text for integers and decimals only?
I cannot find the right answer for my case, so I posted my question here.
I'm validating the form in ASP.NET MVC and looking for the way to validate a text field to allow only numeric and decimal ...
1
vote
1
answer
3k
views
How to manually add MVC client-side validation?
I'm using jquery (unobtrusive) validation for MVC, and I have a field that is not a part of my model, so I'd rather not add it JUST to give it some data annotations.
And, all I need is to ensure that ...
1
vote
0
answers
73
views
Regex to prevent the entering of white space? [duplicate]
I want validate that a username doesn't contain spaces. I want use AZ-az-09 and _ character in my string and ingore another. I have a regex but it is no validating spaces.
[RegularExpression("^([a-...
3
votes
3
answers
5k
views
MVC Client Side Validation Summary not showing when Model is Invalid
I'm using the MVC Validation nuget package called MVC Foolproof Validation.
I'm using it on my model to set a required to true if another model property was empty. The validation part works, as the ...
0
votes
1
answer
1k
views
MVC 5 - can not get globalisation running
I want to add globalization because the site asks the user for a date. And my german user want to type "31.12.1966" and not "1966-12-31".
So I add the nuget-Packages
"jQuery.Validation.Globalize" and
...
3
votes
0
answers
336
views
Custom validation using AddModelError for child viewmodel
I'm having to do some custom validation on a child viewmodel, adding any issues to the ModelState using ModelState.AddModelError(). However I'm presented with an issue trying to get the correct ...
0
votes
0
answers
329
views
MVC validation doesn't work on partial view
I have a partial view containing a user creation form. When I call that form within a main view using @Html.Partial("_CreateUser")and attempt to submit it empty, none of the Data annotation ...
-1
votes
1
answer
319
views
Input validation generating data-* attributes ONLY on Primary key and checkbox type input tags
I've created a sample ASP.NET MVC Core 1.1 web app created using VS2015-Update3. It generates input tags with data -* attributes only on a model property that is a Primary Key, and on a property that ...
0
votes
0
answers
1k
views
ASP.NET MVC input validation to allow only two digit numbers on a model property that is string type
The input values can be any two digit numbers of the form 00, 01,...09,10,11,....19,20,...,99 etc. But following is not working. User can still enter abc and no client side validation occurs. Of ...
3
votes
2
answers
2k
views
Change ASP.NET MVC validation dynamically in Jquery
On one of the view model fields, I have set the min length in ASP.NET MVC Data Annotation attribute.
[MinLength(5, ErrorMessage = "A minimum of 5 digits is required")]
Based on a dropdown selection(...
0
votes
1
answer
107
views
Match regex that doesn't contain pair of tags
I build form to create custom WebForms master pages. I need to validate with regular expression if custom text, that will be placed inside master page, does not contain <% and %> tags and any ...
1
vote
1
answer
4k
views
Validation of properties that require the values of other properties
So I have checked out this answer ASP:NET MVC 4 dynamic validation of a property depending of the current value of another property and it does not cover the issue I am having.
I am using server side ...
0
votes
0
answers
59
views
Conditionally validate collection/list item properties based on parent model value
I have the following view models
public class Step4ViewModel {
[Required(ErrorMessage="Yes/No Required")]
public bool? HaveVehicles { get; set; }
public List<Vehicle> Vehicles { get; set; ...
0
votes
1
answer
119
views
MVC Unobtrusive custom rule only works in one form on client
I built a custom validation rule for one particular field on my MVC 5 app. It works great on the edit form, but when validating that same field on the "create' form, the client side validation does ...
0
votes
1
answer
263
views
MVC Form Validation failed due to two required fields with unused one
I am using MVC ViewModel. There are two radio buttons with
yes or no in a form. If the user selects 'Yes' TextField1 will be displayed and if select 'No' TextField2 will be displayed. Both are ...
1
vote
1
answer
1k
views
ASP.NET MVC handling server side validation on jQuery form wizard/tabs
I'm working on a large form that I'm looking to improve the usability of by sectioning it into a jQuery form wizard (jQuery tabbed panels).
I have already implemented both client-side validation and ...
0
votes
0
answers
120
views
Foolproof package complext model validation
I have:
public class Test
{
[Required]
public string Name { get; set; }
[Required]
public bool Is1 { get; set; }
[RequiredIfTrue("Is1")]
public string Name2 { get; set; }
...
0
votes
0
answers
107
views
ASP.Net MVC: custom client side validation for checkboxes is not working [duplicate]
basically i am showing checkboxes in page and checkboxes generated in loop.
i have create a custom validation using this ValidationAttribute, IClientValidatable
my server side validation working fine ...
0
votes
0
answers
327
views
ASP.Net MVC: How to show validation message when working multiple checkboxes [duplicate]
i am showing many check boxes in loop and i want when user submit form then user has to select at least one checkbox. if no check box is selected then validation message will show at client side and ...
0
votes
0
answers
810
views
Adding class to error-span using unobtrusive validation
I'm trying to get the example shown here to work within my project.
My code currently looks like:
<!-- jQuery.validate -->
@Scripts.Render("~/Bundles/jQueryVal")
<script type="text/...
1
vote
1
answer
671
views
Html.ValidationMessageFor( MyKey ) without being tiedto a model's attribute?
My model does not really represent what my form is posting. Example my Orgs Model which holds orgs helps me generate a treeview the users selects several nodes of the orgs tree and submits a form. The ...
0
votes
0
answers
77
views
Model Validation issue in MVC
Model:
public class Employee
{
public string Id { get; set; }
[StringLength(10, MinimumLength = 5)]
[Required]
public string Name { get; set; }
public ...
1
vote
1
answer
2k
views
ASP.NET MVC 5 and jquery ui datepicker validation
In an asp.net MVC application, I have the following property:
...
public System.DateTime StartTime { get; set; }
...
And, in a view (in a form):
<div class="form-group">
@Html.LabelFor(...
2
votes
1
answer
3k
views
ASP.NET MVC custom validator client-side validation not firing
I have created a custom group validator that ensure that the user has filled in at least one field from a given group. This works when I load the page and submit the form without entering anything.
...
0
votes
1
answer
62
views
MVC5: Custom validations are not triggered when Submit button is clicked
I am creating a selection screen, let say there are two fields "Start Date" and "End Date" and a "Search" button.
I created custom attribute for validating the date fields such that it must fall ...
1
vote
0
answers
530
views
Asp.Net Mvc how to Conditional Validation
I'm trying to build a demo application for gain Asp.Net Mvc 5 development experience. In these days i'm trying to build a site settings.
I've a model named Settings. And there are properties like ...
0
votes
1
answer
980
views
Validation messages from custom model validation attributes are locked to first loaded language
I am working on a multi lingual website using Umbraco 7.2.4 (.NET MVC 4.5). I have pages for each language nested under home nodes with their own culture:
Home (language selection)
nl-BE
some page
...
0
votes
2
answers
103
views
get current user role and redirect to specific action
I'm trying to create different redirection in my Login Action Result in the sense that if a user logs in and is in a Role redirect to a specific view
E.g. If a receptionist logs in redirect to `...
0
votes
0
answers
1k
views
How do you keep MVC validation messages from disappearing when you click on another field?
I have a asp.net MVC/Razor project. One of the views has a series of dropdowns. When you select an option from the dropdown, javascript code checks to see if the option has already been selected by ...
5
votes
1
answer
1k
views
MVC Nested View Model with Validation
I'm trying to put login and register form into same view. I did everything suggested in other questions but my problem still not fixed.
Here is my parent view authentication.cshtml:
@model Eriene....
0
votes
1
answer
566
views
MVC date validation fails with a two digit date
I'm having a terrible time adding a date to a view. I want the user to be able to type in a date like 6/30/15 or 6/30/2015, but the validation keeps failing if I use the 2 digit date. I've tried to "...
0
votes
1
answer
1k
views
How do you find the div that contains a input field with validation error using MVC validation?
I have a mobile version of a website that has multiple "pages". These five pages are all in one view made up of divs that are hidden/shown as they progress from one to another.
So when you first ...
0
votes
4
answers
800
views
How to validate multiple textboxes with MVC?
I have three textboxes and i need to check if one of field is not enter and display error(just one error). Is this possible with MVC validation or i need javascript validation?
@Html.TextBoxFor(m =&...
1
vote
2
answers
65
views
MVC Validation for numbers: one of the inputs needs to be less then [X]
I have the following two properties in my model:
[Display(ResourceType = typeof(WideFormatStrings), Name = "labelDynamicWidth")]
public int? SelectedDynamicWidth { get; set; }
...
0
votes
1
answer
810
views
MVC 5 integer validation when entering a non integer
I am coding a MVC 5 internet application, and have a question in regards to validating a integer value in a view.
I have a model with the following variable:
public int integerValue { get; set; }
If ...
2
votes
2
answers
810
views
How to add validation for a list in a ViewModel
I have the following ViewModel:
public class InvitationViewModel
{
public int id { get; set; }
public string InvitationName { get; set; }
public string Type { get; set; }
public ...
0
votes
1
answer
2k
views
MVC 5 model validation message not correctly displaying
I am coding an MVC 5 internet application and I have a question in regards to validation on a field in a view model.
Here is my view model field:
[Display(Name = "Latitude")]
[Required(ErrorMessage =...