Asp Net Custom Validator Dynamic Error Message
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About asp net custom validator change error message in javascript Us Learn more about Stack Overflow the company Business Learn more about hiring
Asp Net Custom Validator For Multiple Controls
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the asp net custom validator date Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up set errormessage for customvalidator? up vote asp net custom validator example 7 down vote favorite 1 I would like to use a customvalidator control to handle all my validation, but I can't figure out how to set the error message in the code-behind for different checks. Is this possible? asp.net validation webforms customvalidator share|improve this question asked Sep 21 '11 at 18:33 chobo 9,5532387156 add a comment| 2 Answers 2 active oldest votes up vote 10 down
Asp Net Custom Validator Clientvalidationfunction
vote accepted You can set the error message in the OnServerValidate method as you wish based on your validation logic: protected void customValidator1_Validate(object sender, ServerValidateEventArgs e) { if (e.Value.Length < 5) { e.IsValid = true; } else { customValidator1.ErrorMessage = "Length must be less than 5."; e.IsValid = false; } } share|improve this answer answered Sep 21 '11 at 18:54 jdavies 9,53831927 add a comment| up vote 0 down vote For One Control you can do like this..
/* In Code Behind*/ protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e) { if(e.Value.Length == 8) e.IsValid = true; else e.IsValid = false; } share|improve this answer edited Jul 28 at 7:31 Stephan Bauer 5,28622042 answered Sep 21 '11 at 18:57 Hari Gillala 4,722135199 I don't understand when will the error message will show up under the textbox! anyway I want to set it when I click on the submit buton, but how ? –Glolita Dec 7 '12 at 8:03 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign
here for a quick overview of the site Help Center Detailed answers to any asp net custom validator server side questions you might have Meta Discuss the workings and policies custom validator in asp net c# of this site About Us Learn more about Stack Overflow the company Business Learn more about
Custom Validator Client Side
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow http://stackoverflow.com/questions/7504824/set-errormessage-for-customvalidator is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up change customvalidator message dynamically in clientside up vote 0 down vote favorite I wanna change customvalidator message dynamically in clientside by ClientValidationFunction. In java script I have : function valnationalid(source, http://stackoverflow.com/questions/15220797/change-customvalidator-message-dynamically-in-clientside arguments) { if (arguments.Value == ""){ source.errormessage = "custom message here"; arguments.IsValid = false; } else if (arguments.Value == "Something else"){ source.errormessage = "another custom message here"; arguments.IsValid = false; } } and in body:
Party Controls ASP.Net Validators WCF Repeater Regular Expressions Yahoo API iTextSharp FaceBook Charts ListView Tweeter Google CSS SMS DotNetZip Crystal Reports Entity Framework HyperLink RDLC http://www.aspsnippets.com/Articles/Dynamically-change-the-error-message-of-ASPNet-CustomValidator-using-JavaScript.aspx Report SqlDataSource Menu YouTube Twitter HTML XmlDataSource ListBox Tips DataGridView Cryptography Windows Forms LinkedIn WebUserControl RSS Feeds HTML5 Sitemap IIS LINQ DataPager URL Routing SqlBulkCopy OCR ASP.Net 4.5 Master Pages MySQL CSV Stored Procedures JSON Web Services Bootstrap Windows Service DataTable App.Config Visual Studio RadioButton CheckBox Generic Handler DropDownList FileUpload RadioButtonList CheckBoxList Flash HtmlEditorExtender Div Table AngularJS custom validator DataReader DataSet Console Applications FTP DetailsView Password TextBox Enum ComboBox Sponsored SqlDataAdapter OpenXml ClosedXml SiteMapPath Arrays FormView SqlTransaction Web.Config Cookies MVC Data Annotation Forums Contact Search Search Home Categories Forums Contact Search Dynamically change the error message of ASP.Net CustomValidator using JavaScript 23 May 2014 Mudassar Khan 0 Comments 46073Views ASP.NetJavaScriptASP.Net Validators Follow @ASPSnippets Follow @ASPSnippets Here Mudassar asp net custom Ahmed Khan has explained how to dynamically change the error message of ASP.Net Custom Validator using JavaScript.In order to illustrate the functioning with an example, I have created a simple form where a person has to enter either Phone Number or Cell Number and based on what he chooses the validation message of the ASP.Net CustomValidator is dynamically changed using JavaScript. Download View Demo Download FREE APIs to work with ALL kinds of office files - http://e-iceblue.com/free-api Follow @ASPSnippets Follow @ASPSnippets In this article I will explain how to dynamically change the error message of ASP.Net Custom Validator using JavaScript. In order to illustrate the functioning with an example, I have created a simple form where a person has to enter either Phone Number or Cell Number and based on what he chooses the validation message of the ASP.Net CustomValidator is dynamically changed using JavaScript. HTML Markup In the below HTML Markup I have a RadioButtonList to allow user choose whether he has to enter Phone Number or Cell Number, and