Click here to Skip to main content
15,894,362 members
Everything / Validation

Validation

validation

Great Reads

by Edwyn Amador
Handles and validates input typing and pressed keys in TextBox, RichTextBox and ComboBox, displaying custom balloon tips messages
by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
In this blog, we will explore a trick to validate whether any CheckBox inside one CheckBoxList is checked or not.
by vladimir husnullin
Web development using JSON is simple
by Chris Copeland
A managed library for automated dependency injection, contract validation, and custom aspect-oriented decorator implementations

Latest Articles

by Han Bo Sun
Several ways of form field validation using Angular framework
by siliconvideo
This StringBox control implements keystroke validation using regular expressions and a touch of glue logic
by Chris Copeland
A managed library for automated dependency injection, contract validation, and custom aspect-oriented decorator implementations
by siliconvideo
A NumberBox class for number entry, display, range limits and keystroke validation including binary

All Articles

Sort by Title

Validation 

5 Feb 2011 by Eddie Niebruegge
When I Build my project, I get the following error on my e.cancel statement:'cancel' is not a member of 'System.Windows.Forms.DataGridViewCellEventArgs'Here's the code in my event:Private Sub dgvPhysCME_CellValidating(ByVal sender As System.Object, ByVal e As...
5 Feb 2011 by OriginalGriff
Try e.Cancel instead: C# and VB are case sensitive.Additionally, you are using the wrong eventargs: DataGridViewCellValidatingEventArgs is what you should have. See MSDN[^] for details.
5 Feb 2011 by Estys
You handle the wrong event.It must be :private void dgvPhysCME_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) Handles dgvPhysCME.CellValidatingThe DataGridViewCellValidatingEventArgs has a Cancel property.Cheers
24 Jan 2016 by Daniel Brousser
Custom TextBox control for UI input validation
18 Feb 2017 by Member 13009199
Hi,I want to have 2 forms on 1 page, I had duplicated the 1st form and gave it an other ID but for some reason the 2nd forms validation / success messages do not appear in the form page but a blank page. The form is send successfully however.
7 Dec 2009 by nGrafix
Hi giys,i wrote my programme in VS.NET 2008 that takes real numbers separated by commas from TextBox1.Text, sort them and display the sorted in TextBox2.Text.Now i want to add another 2 sorting algorithm that uses the same TexBoxes with different buttons to perform the sorting.I need...
7 Dec 2009 by AspDotNetDev
This seems like a homework question...What do you need help with specifically? Sorting algorithms are well documented online. Have you searched online yet? Wikipedia has some good information. Once you've done that, then come here with specific questions and we'll be happy to assist (so long...
22 Dec 2013 by pogo_sumit
Respected Sir/Madam, I am unable to add validation upon the given time interval. i just want to know the regular expression to validate my given time interval in 12 hour clock format. i will look forward for your kind concern. for example :- (Please state a time between 9:00 AM to 7:00...
15 Apr 2013 by Rahul Rajat Singh
In this article we will try to see how we can use DataAnnotations to perform validations of Model classes in an ASP.NET MVC application.
19 Jun 2012 by A. Ganzer
Validation of input made as easy as possible for Windows.Forms, WPF, console-applications or any other purposes
21 Jun 2012 by Mac12334
Hi allI am building a new page for candidate details.In that page I have added a multi linedTextbox.I have done both server side and client side validation to that textbox.But still it is throwing error.I have validate ('','').I searched in Google but didn't find anything...
21 Jun 2012 by Vani Kulkarni
Check this link below, see if it helps:A potentially dangerous Request.Form value was detected from the client[^]http://forums.asp.net/t/1790823.aspx/1[^]
22 Jun 2012 by Rahul Rajat Singh
This article describes some reusable JavaScript functions that can be used to create the input fields which accept some specific type of data. It also provides functions to validate the data.
27 May 2013 by Member 9905188
In any form with Address field in SP 2010,a menu item or button can be added which will validate the address field and also show a pop up map to locate the address.Mean like required field validator I want to create address validator which can be added in any form to validate and locate the user...
25 Sep 2017 by girishmeena
All the information regarding Ajax file upload control and validation
3 Nov 2014 by Anubhav Goel
I am using the regular expression to validate emails./^([\w-]+(?:.[\w-]+))@((?:[\w-]+.)\w[\w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})(\".+\")?)$/iSo i want to allow the + sign only other special characters are not allowed.What change I need to make in this pattern?Thanks Anubhav
3 Nov 2014 by Kornfeld Eliyahu Peter
http://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx[^]
3 Nov 2014 by Sergey Alexandrovich Kryukov
I don't know what do you want to achieve and why, but '+' is a part of Regular Expression syntax, so the only possible problem I can see is knowing that you can escape any character, in this case, '\+'. I did not see this combination of two characters in your Regex sample, that makes me think...
6 Oct 2013 by Member239258
allow user to enter only a single digit of 0 or 1 in textbox.help me guys, thanks.
6 Oct 2013 by Raje_
Use KeyPress event.Eg.protected void YourTextBox_KeyPress(object sender, KeyPressEventArgs e){ var allowKeys = new[] { Keys.Back, Keys.D0, Keys.D1 }; e.Handled = !allowKeys .Contains((Keys)e.KeyChar);}I hope It will help you.Good luck.
6 Oct 2013 by Thanks7872
Use AJAX FilteredTextBoxExtender Control[^] like this:Regards..
9 Dec 2015 by Member 12196709
if i run, validation just can be work only on symbol "/", if I input the other symbol except / didnt working. I'm not use regex. loop like stop work.if(nama!==""){var i;var list = new Array ("/","!", "@", "#","$","%","%","^","&","*", ...
9 Dec 2015 by Rajdeep Debnath
Please try the below...var a = '09azAZ!'var t = '';alert(a);for(i=0;i57) && (t90) && (t122)) { alert('Not alphanumeric: ' + a.charAt(i)); //return; }}
9 Dec 2015 by Suvendu Shekhar Giri
Why not a simple Regex?Try this-if(nama!==""){ var regex= /^[a-zA-Z]+$/; if(! nama.value.match(regex)){ alert("Full Name must not contain any number and symbol"); return false; }}Isn't that very simple !Note:1. You are saying you are not using regex but,...
14 May 2014 by Member 10556609
Am New To Android . am having one edit text box for entering date time..if i enter date time .it will check date time format validation..Please Help Me any one..
3 Jul 2013 by Manuel john
hi i am fresher in joomla3.0 i need to know about working of forms,contact page,Google maps in joomla and more about i have an a blog backup from posterous how to insert this blog backup to joomla3.0 please guide me urgently....
3 Jul 2013 by Richard MacCutchan
Your question would probably get answered quicker if it was posted in the obvious forum[^].
7 Jul 2014 by Sebastian Solnica
Anti-Forgery Tokens were introduced in ASP.NET in order to prevent Cross-Site Request Forgeries. There are many sites which describe how to use and configure those tokens in your application. But in this post I’m going to show you what exactly…Read more ›
24 Feb 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
In this blog, we will explore a trick to validate whether any CheckBox inside one CheckBoxList is checked or not.
25 Nov 2011 by S V Saichandra
Asp.Net Custom Validator Control to validate file size both client side validation and server side validation
14 Sep 2013 by Rohit kumar6210
Any one Please help me to solve the following error ? Please tell me why the following error occurs ????Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation...
14 Sep 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Please refer the accepted answer - Validation of viewstate MAC failed[^].
13 Feb 2012 by cYpH3r x3r0
Hello Guys,I want my form to be validated using Javascript. I am developing a shopping cart using ASP.NET. I don't want to use the Required_Field_Validator and stuff like that, that comes up with asp.net. I want to use plain javascript. I also don't want to add my javascript programmatically....
13 Feb 2012 by RDBurmon
30 Jul 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
We will explore the technique in jQuery to validate the ASP.NET GridView.
4 Sep 2011 by dharmesh024
I am trying to update the partialview in which i used ajax.beginform. normally, first time it validate on client side but when i refresh the partial view innerHTML using outside button event, it is no more doing clientside validation on button submit.It is working fine in google chrome but...
29 May 2012 by chetan thummar
Hello Dharmesh,The code u have provide here is working fine.I have tried in all of three browser which u mentioned those are google chrome, IE 9 and Mozilla. Every time it validates and working nice.
11 Jun 2014 by Sreenivas Chinni
This is a tip to add custom data annotation with client validation in ASP.NET MVC 5
22 May 2010 by prathameshpitale
I Have Three aspx pages, With one Master page.I Have Connected Three pages with MAster Page, I am using Ajaxtoolkit for validation (RequiredField and Filteration and validationtools i.e Summary to display).On StudentData Page every Validation is OK, Ween I CLick on Sumbmit Button All is...
22 May 2010 by Christian Graus
prathamesh1234 wrote:I Am new to aspx.net, i Donot Know Much Thing. Please Help me.Then why on earth are you trying to learn three things at once, and obviously getting stuck ? Are you a student at this school ? Do they have a class in .NET ? prathamesh1234 wrote:URGENTNot for us,...
22 May 2010 by prathameshpitale
@Christian GrausHey Thanx for Reply. OK i am sorry if URGENT Word have Hurt you.ya i am studying in School and trying to learn .Net Myself.Can you Help for my above answers?
22 May 2010 by Matthew Dennis
You have two options to fix your problem which is the links on the left are running the client side validation.1. Change the left side LinkButtons to HyperLinks. -- OR --2. Set the CausesValidation property on the LinkButtons to false.
11 Jul 2012 by R. Giskard Reventlov
This will get you started: Exploring ASP.NET Validators[^]
31 Jul 2012 by NothingToLoose
ASP.NET validation control perform validation at client side...because when ever validation is perform by these controls its display error (if any) without post back of that page...
3 Jul 2015 by Jariwala Amin
Hello Friends, I am using RequiredFieldValidator to validate my asp.net controls. But I'm facing some weird problem because this is not going to happen in this case i did the same thing already in my another websites.My aspx code is below:
4 Jul 2015 by shailendr
please check ur controltovalidate property of validation..............
4 Jul 2015 by Jariwala Amin
I found somthing guyz. When I remove my Gobal.asax file all validations are working properly!! I don't understand. I only have this in my Global.asax file.using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Routing;using...
13 Dec 2012 by Member 7708012
Hi guys, got a problem with the standard asp.net validators in a project.Basically I am adding the following to my form:
13 Dec 2012 by Member 7708012
As it turns out it was to do with the URL re-writing. I had Quickly implemented a custom form control off an MSDN article to combat the re-writing on the post back. What the control did was to remove the url from the action attribute, however it also removed the on submit action.So to solve...
12 Mar 2010 by goldeneyeonline
Hello everybody!I seem to have a very common problem, about which I have Googled for many hours now, but could not find a solution...My Custom-Validator in ASP.NET just won't work!
14 Mar 2010 by nishantsagar83
hi,try switching to design view and then back to html view and code view...sounds stupid.. but it does work sometime... thing's that sometimes the methods are not bound properly and switching between modes makes studio bind them again properly...do let me know if u find some proper...
15 Mar 2010 by goldeneyeonline
Hi nishantsagar83!Thank you very much for your answer!Since I usually only use the sourcecode tab, i was really hoping this would do it... but it didn't:(I mean, even when i click on the error text in design view, then my cursor jumps to the function for the Custom Validator, but it still...
15 Feb 2016 by Oğuzhan Soykan
Automated monkey or specific validations for WCF or REST services with Fluentvalidation and CastleWindsor
7 Jul 2011 by Dweatherford
I have a drop down list that has several options in it but I need to have a custom validator which does not allow the user to select 4 of the potential options in the drop down list. Any help would be greatly appreciated.
7 Jul 2011 by Sergey Alexandrovich Kryukov
First of all, even if you implement such behavior, it cannot be called "validator". A "validator" is something which validates data after it is entered, but you want to filter out the input (selection) itself.I fear to say such behavior is too far from expected UI behavior and would be very...
29 Aug 2017 by Valerii Tereshchenko
Asynchronous validation for MVVM(WPF)
22 May 2011 by duonglg
i have 2 column PRICE and PAYMENT in Datagridwhen i change value of 1 any cell in this Datagrid, other cells also change the value.Example:PRICE | PAYMENT 100 | 80 | 20 | 10 | 10 | 5 | ...
22 Feb 2011 by imsauravroy
A basic introduction on how to use data annotations for validating MVC models, which solves basic validation issues
22 Oct 2013 by Member 10321925
I have 3 TextBoxes in my window.When i enter wrong charecters into the TextBoxes ,It should show error by using validations.I'm doing this in WPF, please help me with the codeThis is my XAML code
22 Oct 2013 by Kenneth Haugland
I find this easyer to do in code behind. Look here[^].
19 Jan 2019 by Mr. Tomay
For ValidationError, usually we use MessageBeep function.But unfortunately MessageBeep is asynchronous (After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound asynchronously.).Where Beep function is synchronous (Generates simple tones...
12 Jan 2012 by Addy Tas
Hi,From the trail I can't directly figure out if you're just not happy with the frequency of synchronous call and/or you can't get the async to work. If the latter is the case I suggest that you post the non working code.Anyway what may be of interest for you is to check out a third...
19 Jan 2019 by neelbhai
////////////////////Sound.h #pragma once class Sound { public: Sound(); ~Sound(); void MakeSound(); BOOL Quit = false; BOOL mkSound = false; }; ////////////Sound.cpp #include "stdafx.h" #include "Sound.h" UINT SoundThread(LPVOID pParam) { Sound * mSound = (Sound*)pParam;...
14 Apr 2016 by Member 11682666
Hiii All,i have a login form with the below code $(document).ready(function () { $('#loginForm').bootstrapValidator({ framework: 'bootstrap', excluded: [':disabled'], ...
14 Apr 2016 by Zaeem Shamsi
You can disable the login button if form is not valid with angular directive ng-disabled="loginform.$invalid".It'll disabled your button if form is invalid.your login button would be like
20 Jul 2013 by thedude9
How do you approach contextual validation?
28 Nov 2010 by Uwe Keim
Just a short Amazon hint: The book Patterns of Enterprise Application Architecture[^] by Martin Fowler was a valuable source for me. Maybe it is helpful for your task, too.CheersUwe
28 Nov 2010 by thedude9
Thanks Uwe, yes that is a great book. But it doesn't have anything about validation.
14 Apr 2013 by Nestor Marsollier
A point of view about business validations on enterprise applications
4 Mar 2017 by mimtiyaz
HelloButton click event is not firing inside the bootstrap modal window when I apply validation inside the modal window. If I remove the bootstrap validation, the button click event is firing.Anyone try to fix it.Thanks,ImtiyazWhat I have tried: ...
4 Mar 2017 by Graeme_Grant
You need to wrap the inside a ... for the post-back to occur. Note: Only one ... per Asp.Net page is supported. MVC does not have this restriction.To get around this restriction you will need to use javascript/jquery/etc...[edit:]...
15 Jul 2020 by ||Memo||
Hi guys, i have a problem about FluentValidation. I am taking this error when i am starting app: System.InvalidCastException: 'Unable to cast object of type 'DevFramework.Northwind.Entities.Concrete.Product' to type...
15 Jul 2020 by Richard Deeming
The error message is quite clear - your Product class does not implement the IValidationContext interface. It looks like you're passing in the wrong value to your ValidatorTool.FluentValidate method. This appears to be the same code that was...
15 Jul 2020 by ||Memo||
Guys i found the solution. public class ValidatorTool { public static void FluentValidate(IValidator validator, object entity) { var context = new ValidationContext(entity); var result...
19 Aug 2014 by Member 10692229
How to check whether Textbox empty and if it is empty should display error using Textbox KeyPress Event and shouldn't be able to move to next control
19 Aug 2014 by Dilan Shaminda
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { if(String.IsNullOrEmpty(textBox1.Text)) { MessageBox("Textbox cannot be empty","Title", MessageBoxButtons.OK, MessageBoxIcon.Error); ...
21 Mar 2014 by Member 10686581
I'm trying to build a form for a user to input an ID number, in the format of 'LLLNNNN' (L=letter, N=number) so for example JNH8383 and anything other than that should be determined as invalid. Also it needs to check for any ID's beginning with "SOS" and "PAN" when these are entered it needs...
21 Mar 2014 by Pheonyx
You have various options available to you for this sort of feature.One option could be to use "Masked Text Box"MSDN - Masked Text Box[^]However you would still need to write some validation to check for your SOS and PAN values which could be done with a simple "In String" check in the...
21 Mar 2014 by Richard C Bishop
You would probably need a regular expression for the ID number validation. You can create one with this[^] if you are not familiar with RegEx already.For the second part, a simple if statement and the use of the substring()[^] method would suffice for this.
21 Mar 2014 by Marcin Kozub
Use MaskedTextBox:http://msdn.microsoft.com/en-us/library/vstudio/bb763018%28v=vs.100%29.aspx[^]To validate control use Control.Validating event:http://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating%28v=vs.110%29.aspx[^]To display validation error use...
21 Mar 2014 by Peter Leow
Assuming the 3 letters are capital, adapt the following example:using System;using System.Text.RegularExpressions;public class Program{ public static void Main() { string input = "PSN1234"; Regex regex = new Regex("^(?!PAN)(?!SOS)[A-Z]{3}\\d{4}$"); ...
18 Jan 2015 by Member 11373200
am trying to implement custom client side validation, and i was wondering can i access the value to validate in the GetClientValidationRules just like the value in IsValid??thanks in advance
23 Jan 2015 by Member 11373200
I ended up using an ajax call inside the javascript validation file where I can access the value to be validated as follows:$.validator.addMethod("custom-validation-name", function (value, element, params) { var valid = false; $.ajax({ url: "/Controller/Action", ...
19 Jan 2021 by rtksmithjoton123
TryValidateModel can only justify whether it is valided successfully, but it can not give the error message. How can do it. What I have tried: I test the TryValidateModel , and find some document, but no this method to realize getting the...
19 Jan 2021 by Sandeep Mewara
You need to use ValidationSummary to get details of the error. An example: Validate Model Programmatically in ASP.NET MVC | BinaryIntellect Knowledge Base[^] Read more here: ValidationSummary in ASP.NET MVC[^] ValidationSummary Class...
3 Oct 2011 by Ben Hanson
The definitive approach to filtering input text. Includes configurable error display.
5 Apr 2011 by Michael Waguih
Hi all,I have a Cell in a DataGridView where I am validating its contents, when validating I tried to change the value of this cell within the Cell_Validating event handler method using this :dataGridView1["Name", e.RowIndex].Value = "NAME";But it didn't work.What can I use...
5 Apr 2011 by Orcun Iyigun
If the DataGridView is databound, you shouldn't directly modify the content of the cell. Instead, you should modify the databound object. You can access that object through the DataBoundItem of the DataGridViewRow :MyObject obj =...
3 Mar 2014 by Member 10603307
I've got three checkboxes and I need validation so that you can only text one of them. I've got the code so you can only select one of the text boxes (that code looks like this)private void toc_Blockleave_CheckedChanged(object sender, EventArgs e) { if...
3 Mar 2014 by Paddy84
Use == false for each CheckBoxif (rdo_ApplySelectedCodeToRD.Checked == false && rdo_LeaveRDAlone.Checked == false && rdo_SetRDToZR.Checked == false) { MessageBox.Show("You must choose a Rest Day Option"); return; }
3 Mar 2014 by King Fisher
if (toc_Blockleave.Checked ==false && toc_Swap.Checked==false && toc_Unavailability.Checked == false ){}use '&&' operator not'&'
3 Mar 2014 by phil.o
I would use just one event handler for all three checkboxes (btw, you know radio buttons would fit better here, don't you?) and validate using XOR function.This way:private void CheckBox_CheckedChanged(object sender, EventArgs e) { CheckBox box = (CheckBox)sender; if (box !=...
5 Nov 2012 by Ashok26
Hi,I have few panels on page.In one of the panels, there is a button with few editable controls.User can edit these controls' values and use the button to see derived values.However, we have a requirement to prompt user if the user moves out of the panel and goes to another panel...
5 Nov 2012 by manognya kota
Hi,As per my understanding, i guess..1.You can have a hidden field flag to indicate whether the button was clicked or not.2.In the client side events of the controls in Panel2, you can check whether that flag is set or not.3.Then focus/display an alert message as...
15 Sep 2015 by Member 11247784
I try to use model base clientSide validation in MVC 5 on my partial view and i add references on my layout page but that is not able to work.but when i add...
15 Sep 2015 by F-ES Sitecore
You should be able to add them to the layout, just make sure they appear after the reference to jquery. If it's still not working you'll need to post the script references in context.
15 Jun 2012 by coolnavjot31
In this article we will see how we can validate a TextBox and DropDownList using JavaScript.
22 Jan 2015 by Member 10736689
Hi,I have a compare validator on my textbox(code below) in my page load it sets the value to compare. I want the value in the textbox to be less than the current date. If i select a value less than the current date it stills give me an error. any thoughts?
11 Oct 2013 by ASP.NET Community
The CompareValidator control compares the value of one control to another, or to an explicit value in the control's ValueToCompare property.
11 May 2011 by Super Lloyd
A much simpler composite application library.