Customvalidator Sender. 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 change custom validator error message using javascript and policies of this site About Us Learn more about Stack Overflow asp.net custom validator change error message server side the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation javascript form validation error message Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it asp.net custom validator display dynamic only takes a minute: Sign up How can I rewrite the ErrorMessage for a CustomValidator control on the client? up vote 6 down vote favorite 1 I have a CustomValidator that is validating a telephone number for several different telephone numbering schemes. The client-side javascript looks like this: validatePhoneNumber(sender, args) { cleanNumber = args.Value.replace(/\D/, ""); country = $("#" + CountryID).get(0).value;
Asp.net Custom Validator Client Side
switch (country) { case "North America": args.IsValid = validateNAPhoneNumber(cleanNumber); if (!args.IsValid) sender.errormessage = "* Not a NA Phone #"; break; case "UK": args.IsValid = validateUKPhoneNumber(cleanumber); if (!args.IsValid) sender.errormessage = "* Not a UK Phone #"; break; ... } } The actual validation takes place properly, and the CustomValidator has the correct IsValid property at all times. The sender.errormessage, however, seems to be rewritten just after this function call to it's default value. How can I change the errormessage value, and make it "stick"? asp.net javascript validation client-side ecma262 share|improve this question edited Aug 5 '09 at 2:15 asked Aug 4 '09 at 22:46 Dustman 2,09772638 add a comment| 9 Answers 9 active oldest votes up vote 3 down vote The best way to change the error message of a validator control with image is: sender.innerHTML = "YOUR HTML WITH ANYTHING COME HERE" share|improve this answer edited Jul 25 '15 at 12:05 Falko 6,79382150 answered Jun 13 '12 at 4:47 Satyavir Yadav 312 add a comment| up vote 3 down vote function dateofbirth(source, args) { var dtcDOB = document.getElementById('<%= dtcDOB.Clie
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
How To Display Error Message In Javascript
this site About Us Learn more about Stack Overflow the company Business asp customvalidator Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask custom validator in asp.net example Question x Dismiss Join the 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 http://stackoverflow.com/questions/1230281/how-can-i-rewrite-the-errormessage-for-a-customvalidator-control-on-the-client up Custom validator error text through javascript? up vote 0 down vote favorite I want to set ASP.net custom validator error parameter text through client side javascript. How can access it via sender, args parameters in my function? javascript asp.net asp.net-2.0 share|improve this question asked Oct 25 '10 at 6:52 Zo Has 5,0201655123 See also stackoverflow.com/questions/1230281/… –Dexter Oct 25 '10 at http://stackoverflow.com/questions/4012387/custom-validator-error-text-through-javascript 7:20 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted All you need to do is define the callback method in the ClientValidationFunction property of the CustomValidator definition:
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/Display a dynamic message with customvalidator - using javascript Display a dynamic message with customvalidator http://forums.asp.net/t/349096.aspx?Display+a+dynamic+message+with+customvalidator+using+javascript - using javascript RSS 11 replies Last post Nov 28, 2010 06:43 AM by aa3wad ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered http://www.aspdotnet-suresh.com/2010/08/changing-validator-error-message-in.html Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply joegass None 0 Points 5 Posts Display a dynamic message with customvalidator - using javascript Sep 26, 2003 error message 07:23 AM|joegass|LINK I've built a customvalidator that checks a string, against a set of disallowed words What I'd like to be able to do is change the errormessage that is displayed according to which particular word was found. Easily done on the server side, just by changing the property, but I'd like to be able to do it asp.net custom validator clientside... Currently I'm having to resort to an alert, but since all more other validation controls show their error messages on the page I'd like to continue this Here's an abridged version... Thanks Reply jerbos None 0 Points 6 Posts Re: Display a dynamic message with customvalidator - using javascript Sep 29, 2003 02:45 PM|jerbos|LINK You should be able to dynamically change the errorMessage of the CustomValidator by setting the "innerText" property in your client side script: source.innerText = "This is invalid"; Hope this helps, Jeremy Bostron [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. Reply joegass None 0 Points 5 Posts Re: Display a dynamic message with customvalidator - using javascript Sep 30, 2003 06:44 AM|joegass|LINK Thank you very much! It worked great, now
asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies Home Asp.Net Ajax Gridview JavaScript SQL JQuery OOPS Concepts MVC Interview Questions Trace Mobile Contact how to change the error message of custom validator dynamically using asp.net By: Suresh Dasari Aug 22, 2010 Categories: Asp.net , validations Introduction Here I will explain how to change the error message of custom validator dynamically using asp.net. Description I have one textbox, one button and one custom validator to validate the textbox whenever user clicks on button.In customvalidator I have taken ClientValidationFunction="ClientValidationFunction" this clientside function is used to send error message dynamically by using sender object. This sender object will display ErrorMessage dynamically.