Click here to Skip to main content
15,894,291 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 Updated

Validation 

5 Nov 2018 by #realJSOP
Validation should be performed in the view or viewmodel. Check this article: Validation in WPF[^]
13 Nov 2019 by #realJSOP
You don't disable commands - you disable the controls that invoke them. The view should be able to detect the error status and disable a control based on that status. That's how it's supposed to work.
5 May 2011 by 555336
Hello, I have textbox on my form, the details are below:So, I want to know, how to NOT save this pretext on the textbox also? I mean only blank field and the pretext must not be saved if the user has not typed anything on the textbox.
13 Sep 2012 by __TR__
You can use length[^] property in JavaScript to validate the text box input in onchange[^] event.You can use isNaN()[^] to check if the value entered is numeric or not.
26 Jul 2012 by _Amy
Have you tried searching Google[^]? Never feel lazy to use google.. --Amit
3 Aug 2012 by _Amy
Hi,Try this:HTML:JAVASCRIPT://Restrict the user to key-in chrectors and other special charectorsfunction onlyNumbers(evt) { var e = event || evt; // for trans-browser...
12 Sep 2012 by _Amy
It's not possible to validate a HTML control using RequiredFieldValidator. If you want to validate your HTML control client side only then you need to use JavaScript.RequiredFieldValidator is used only for server controls.--Amit
19 Aug 2012 by _Amy
Hi, Try setting the property CultureInvariantValues="true" in your CompareValidator .--Amit
6 May 2014 by _Asif_
Try below one. ^[A-Za-z0-9]{6,15}$-Asif
6 Oct 2014 by _debasis
Hi Mahesh, I think you can try with this rules( 'remove', rules ); Hope this helps. Thanks
19 Jun 2012 by A. Ganzer
Validation of input made as easy as possible for Windows.Forms, WPF, console-applications or any other purposes
10 Mar 2013 by A.Ebrahimi
Problem : fill Drop-down list with state and city, by Ajax on client side. Then on post-back this will raise error : Invalid post-back or callback argument...I have found this look at this Microsoft code:
16 Jan 2014 by Aarti Meswania
if you want that user can not insert any special char then handle it in cell_keypress eventand if e.key is special char then handle it using e.handle = true;Happy Coding!:)
3 Jul 2013 by Aatif Ali from Bangalore
You can refer following linkshttp://webcheatsheet.com/javascript/form_validation.php[^]http://www.w3schools.com/js/js_form_validation.asp[^]Aatif Bangalore
13 Sep 2012 by abcforcode
you can use maxlenth property of textbox, by using this property you are able to give length of your choice.
15 Jul 2012 by Abdul Quader Mamun
var value = "a";var reg = new RegExp("[A-Za-z]");if (!reg.test(value)) { return false;}try with this.Thanks,Mamun
19 Jun 2011 by abdulmaajid
Hi, This is my email validation using Jquery , email: function(value, element) { // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/ return this.optional(element) ||...
4 Oct 2013 by abey e mathews
Is any free javascript class common for all type of client side form validation(Javascript)?
9 May 2012 by Abhi KA
try this linkhttp://www.aspxcode.net/free-asp-net-validation-source-code.aspx?Topics=How%20to%20Use%20ValidationSummary[^]
11 Jun 2014 by abhicoolhot
Hi,Am creating one executable file using c# which has to validate the content of text file present in fixed length format (say for fixed length is 30). In case if fixed length was not in defined format then it should be caught in exception.Please advice am not getting the scratch to...
11 Jun 2014 by abhicoolhot
Hi,Can you advice how to clear the content of the cell (B2:E4) in excel sheet using c#.
11 Dec 2010 by Abhinav S
A good discussion here[^].
1 Jan 2012 by Abhinav S
If you want to use Javascript, here[^] is a sample article that you can look at.You can also look at integrating validation controls with the gridview at runtime as discussed here[^].
8 Jul 2012 by Abhinav S
That is not too difficult.Try if ((myControl.Text.Length != 7) && (myControl.Name.ToString() == "txtTelNo") && (myControl.Enabled)).
3 Aug 2012 by Abhinav S
Have a look at the RequiredFieldValidator[^].This article[^] should also give you some updates.
18 Jan 2013 by Abhinav S
The easiest would be to handle the keydown[^] event and only allow 12 to be entered.Some other articles that might provide some insight -http://help.dottoro.com/ljlkwans.php[^]http://blog.pothoven.net/2008/05/keydown-vs-keypress-in-javascript.html[^]
22 Jan 2014 by Abhinav S
[DataType(DataType.EmailAddres...
6 Jun 2012 by abhinav_soni
Very simple XML based framework for client and server side validation frameworks in Java.
15 Jul 2012 by abhinavvijay
function onlyAlphabets(e, t) {try {if (window.event) {var charCode = window.event.keyCode;}else if (e) {var charCode = e.which;}else { return true; }if ((charCode > 64 && charCode 96 && charCode
4 May 2020 by Abhishek Duppati
An alternative for Data Annotations in MVC would be the Validation Application Block. We can consider using the Validation Application Block if we want to encapsulate validation good practice into easily maintainable code that can be reused. With...
27 Jan 2013 by Abhishek Pant
Hi Ranga,Change validation group for cancel button(I changed to 0) this will generate validation error(if required fields are blank) only when you click save button in your webpage.
16 Jan 2011 by abi1988
I am using asp.net membership for my web application.I need my users to choose their own secret question and answer in a separate page after their successful login.What is the method to insert the secret question and answer into database using asp.net membership?
4 Feb 2014 by Abid Shk
remove the property display none of requiredfieldvalidatorprovide initial value to requiredfieldvalidator
4 Feb 2014 by Abid Shk
suppose initial value is 0 assign this value to ur textbox at design time or load time when user change this value to 10 and again insert 0 then it will work its better u use javascript function valid() { var v_type =...
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...
26 Jul 2013 by Adhiraj Jaryal
I've made this vdeo, just now..... Hope you will be benefited ... Have a nice time.....http://www.youtube.com/watch?v=LAHkjpZxTiM[^]
10 Jun 2015 by Adil S
I was asked a question in an interview regarding validation with data annotations in MVC.I have a drop down list and two text boxes.If some value is selected from the drop down (say "XYZ"), then the apply validation on textboxes to be required else, textboxes can be left blank on...
2 Jan 2013 by Aditya Magotra
hi,Set property ValidateEmptyText="true" for custom validator
10 Feb 2011 by Aescleal
There's a simple C++ idiom you can use to read an object of any type with an extraction operator and check to see if it's been read successfully. It's only a couple of lines:int n = 0;if( std::cin >> n ){ std::cout
21 Jun 2016 by Afzaal Ahmad Zeeshan
What do you mean by validating the controls? The data of the controls is validated, instead of the XAML controls. You can do so, such as, Suppose you have to "validate" that the user must enter the username to be of length 5-25. You can validate the input using the C# code (or VB.NET if...
29 Jul 2019 by Afzaal Ahmad Zeeshan
All the errors are self-explanatory, what help you want? I will talk about a few, the first error that I see in the line is, Quote: The attribute 'href' in tag 'link rel=stylesheet for fonts' is set to the invalid value '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css'....
16 Jul 2012 by Afzal Shaikh
Use below regular expression.change ControlToValidate with the textbox name and ValidateGroup.
15 Nov 2019 by Ahmad_kelany
Hello everyone, I have a ValidatableBindableBase class that implements INotifyDataErrorInfo interface, and INotifyPropertyChanged interface. The validations depending on data annotations and the custom validations are working fine. The problem is when the text box fails to convert the input...
10 Sep 2017 by Akbar Giffary
hi, i want to test/check when cells in data gridview is empty and when clicked it shows label like "there's a empty data in cell", thanks before If dgvdatakaryawan.Item(e.ColumnIndex, e.RowIndex).Value.ToString.Length = Nothing Then lblKET.Visible = True Else ...
31 Jul 2013 by akhil.krish
Hi iam using clear function Public Sub ClearTextBox(ByVal root As Control) For Each ctrl As Control In root.Controls ClearTextBox(ctrl) If TypeOf ctrl Is TextBox Then CType(ctrl, TextBox).Text = String.Empty End...
31 Aug 2015 by Alexander Siniouguine
You should be able to get errors when settings the parameters: Employee emp = new Employee(); try { emp.IdNumber = 9999999; } catch (ValidationException ex) { ...
13 Sep 2012 by Ali_100
well now i have a textbox ,i have to validate it on blur that it must enter only 9 or 10 number of digits& another textbox has to be validate byI am working in asp classic.well now i have a textbox ,i have to validate it on blur that it must enter only 9 or 10 number of...
26 Mar 2017 by aln668
I'm trying to create a page where users enter some numeric fields, which are then processed by an external dll on the server. Calculation requires client-side validation, such as on intervals (calculation takes a long time, because it's very complex). These intervals are saved on the database...
12 Dec 2012 by Am Gayathri
Windows authentication is Clint side validation or server side validation?
22 May 2013 by Am Gayathri
My application is developed in vb.net.How can i display a message if my dataset retries no record?please helpi tried if (dataset.table.count >0){}else{ message}end ifbut it doesn't showing message if table has no records.so please share your valuable thoughts
8 Jul 2012 by AmitGajjar
Hi,Here is one of the solution,1) You need to use ASP.NET validation control instead of manual validation from codebehind.2) You need to assign validation group property from code behind. Useful linksValidation Group MSDN[^]Validator Controls in ASP.NET[^]Validation...
31 Aug 2012 by AmitGajjar
Hi,You can use Page.IsValid[^] property to check if validation succeed. if it returns false then you should not insert your record in database.So this property will be checked before insert function.Thanks-Amit Gajjar
30 Jul 2015 by Amrik Singh
Display="None" is the trick.
15 Sep 2015 by Andy Lanng
HTML 5 supports pattern and number type:Note: The pattern attribute of the input tag is not supported in Internet Explorer 9 and earlier versions, or in Safari.
5 Feb 2019 by Anilananda
Hy guys can anyone tell how to do form validation with angularjs in asp.net (.aspx page Not MVC) i want to use runat="server" and angularjs bouth from form validation , can any one tell is it possible or not. if possible how to do this? What I have tried: Here is my code
29 Jul 2015 by Animesh Datta
Hello ,You have to add ValidationGroup="A" in TextBox also .thanks
6 Mar 2015 by AnoopkumarS
objLoanApp.birthdate = DateTime.ParseExact(txtbirthdate.Text,"dd/MM/yyyy",null)
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
4 Jun 2013 by Anubhava Dimri
Hi Everybody,I have a class Customermodel in which have birthday,birthmonth,birthyear properties.So i am trying to create a valid date Rules for client side that but i am not able to create it.I am facing issues at the time of birthday. because it is depend on birthmonth and...
20 Aug 2012 by Anuja Pawar Indore
Try thisvar dt = new Date(joinDate); var dt2 = new Date(confDate); var myDate = dt.getDate() var myDate2 = dt2.getDate(); if (myDate
27 May 2014 by April Fans
Hi, you can validate your html text box with javascript:*Requiredfunction...
31 May 2022 by Aravindba
Hi, First spilt pan numbers and pass the spilt values for each functions for verify it, Here all function must return false, otherwise PAN number is incorrect. In fourth position i pass characters to check as "ABCFGHLJPT", bcz u mention 4...
1 Jul 2013 by aravindnass
heyy.. I am using a regular expression validation for Email Address... There is two type of Email like 1. xxx@xxx.com2. xxx@xx.co.inCurrently My validation expression is :-ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"But in this condition it...
8 Jul 2013 by aravindnass
heyy.. I want a regular expression for allow only alphanumeric,space and hypen in a textbox Any regular expressions??
28 Nov 2013 by aravindnass
heyy.. I am using a textbox and a button tag ...when I use html 5 validation (required) ..it is not working ...in IE ..here is my code :- ...
15 Oct 2012 by arshad alam
Code for designer page :
22 Jan 2017 by Arun Maiya
change the code fromif (needInput = false)toif (needInput == false)that should work!
8 Jul 2013 by ArunRajendra
You should be able to find it in this site. http://regexlib.com/[^]
6 Dec 2009 by Ashish Sheth
No need to count the commas.Use Textbox1.Text.Split(',').Length. It gives you the count of the numbers added in the textbox separated by comma.
25 Jun 2012 by AshishChaudha
For this you can also use FilterTextboxExtender of Ajax. You can also set only for alphabets or both.
26 Jul 2012 by AshishChaudha
Try this function CalculateGPer() { var Form = document.frmReg; var txt1= Form.txtBox1.value; var txt2= Form.txtBox2.value; var addition1= (Number(txt1)+Number(txt2)); if(!isNaN(Per) &&...
21 May 2015 by AshishSarang
portion of my code is as below @for (int i = 0; i @Html.DisplayFor(x => x.UtilityLineItems[i].Line_Item_Name) @Html.TextBoxFor(x => x.UtilityLineItems[i].Value_1) }Value_1 is having...
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 Ashok26
We are using validation controls and callout extender to show validation messages.Can we restrict user to fix the error before moving to next field?
9 Jan 2016 by Ashutosh Dutondkar
Public Sub CheckEmptyTextbox(ByVal groupbox As GroupBox) Dim txt As Control For Each txt In groupbox.Controls If TypeOf txt Is TextBox Then If txt.Text = "" Then MsgBox("Fill Details To Proceed",MsgBoxStyle.Exclamation) Exit...
11 Jan 2016 by Ashutosh shukla207
hello friends ... i have to use custom validation in my asp form . but OnServerValidate function is not being called. my code is below :-source code :
26 Jun 2013 by askquez
i have html form which include Five input text fields and one drop-down (select) field.These text fields are showing in form with respect to drop-down options mean if i selected option 1 then three text fields will be showing and for option 2 ( 4 text fields ).I am using jquery for hide...
11 Oct 2013 by ASP.NET Community
Garbage in, garbage out. You can avoid data cleanup tasks on the backend by avoiding bad data coming in.  ASP.NET validation controls and third party
11 Oct 2013 by ASP.NET Community
ASP.NET Validation Controls are powerful server controls that are used for validating user input.  These controls provides both server side and
11 Oct 2013 by ASP.NET Community
The RequiredFieldValidator control is used to ensures that a input field is not skiped inthe entry. The control fails validation if the value it
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 Oct 2013 by ASP.NET Community
The RegularExpressionValidator control confirms that the entry matches a pattern defined by a regular expression. This type of validation allows you
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 Oct 2013 by ASP.NET Community
A ValidationSummary control is displayed when the IsValid property of the page is false. It "polls" each of the validation controls on the page and
11 Oct 2013 by ASP.NET Community
The customvalidator control allows writing custom validation for a control. So, if the others validators: RangeValidator, RequiredFieldValidator,
11 Oct 2013 by ASP.NET Community
 Today I will show you the message bar which I normally used to display the standard place to display the messages like confirmation, errors,
11 Oct 2013 by ASP.NET Community
This article explains how to make validation on checkboxes and remember the selected checkboxes' values in DataGrid/GridView etc, together. This will
11 Oct 2013 by ASP.NET Community
It is better to use javascript functions for validating numeric values rather than Validation Controls.We can restrict a textbox to allow only
7 Dec 2009 by AspDotNetDev
VB does not use a double equal sign to test for equality. It only uses a single equal sign. Try:e.Handled = (e.KeyChar = " ")Also, it doesn't use semicolons to end lines.
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...
9 Dec 2009 by AspDotNetDev
Sounds like you want us to make your regular expression for you. What particular trouble are you having creating your regular expression?
16 Mar 2018 by ATeDe
Hi j snooze I think, this is what you might looking for? I'm not very familiar with Forms and all that jazz in VB.NET, also tomorrow we have St Patrick celebration here in Ireland, so I wrote quickly this piece of code. txtBoxes array of string simulates content of your real TextBoxes. This...
17 Mar 2018 by ATeDe
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' Button to validate Phone numbers typed into TextBoxes Dim emptyTextBoxes = From txt In Me.Controls.OfType(Of TextBox)() ...
30 Jul 2012 by atjoshi
private void button1_Click(object sender, EventArgs e){ int number2; if (int.TryParse(textBox1.Text, out number2)) { textBox2.Text = ("tryparse method succeed"); } else { textBox2.Text=("value entered is not numeric"); }}
1 Jul 2014 by Ayush1857
How to show error message if user misspelled gmail.com(like gaiml.com),yahoo.com in email id of registration form then show error message in asp.netthanks in advance
1 Jul 2014 by Ayush1857
How to create email address checker to check only valid email registered with valid domain like gmail,yahoo.
16 Nov 2020 by Barcelonista Naser
I have a jQuery selectable widget in my razor view which displayed as an and updated from a comma separated string in SQL Server table just like below:@{ var color = Model.AvailableColors.Split(','); foreach (var clr...
22 May 2013 by Basmeh Awad
If ds.Tables(0).Rows.Count > 0 Then'Do what you want to doelseMessagebox.Show("No Records Found")End If