Change The Error Message Of Custom Validator In Javascript
Contents |
here for a quick overview of the site Help Center asp.net custom validator change error message Detailed answers to any questions you might have Meta Discuss custom validator not displaying error message the workings and policies of this site About Us Learn more about Stack Overflow the
Custom Validator Not Showing Error Message
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Custom Validator Javascript Function
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 up Dynamic error message for custom validator clientside up vote 14 down vote favorite 1 I am using a custom asp.net custom validator change error message server side validator to call a javascript function for validation. My problem is that I need to be able to change the error message dynamically. Here is the code:
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 Us
Set Validation Error Message Javascript
Learn more about Stack Overflow the company Business Learn more about hiring developers javascript form validation error message or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack asp.net custom validator display dynamic 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 How can I rewrite the ErrorMessage for http://stackoverflow.com/questions/5394861/dynamic-error-message-for-custom-validator-clientside 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; switch (country) { case "North America": args.IsValid = validateNAPhoneNumber(cleanNumber); if (!args.IsValid) sender.errormessage = "* Not a NA Phone #"; break; http://stackoverflow.com/questions/1230281/how-can-i-rewrite-the-errormessage-for-a-customvalidator-control-on-the-client 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,78572150 answered Jun 13 '12 at 4:47 Satyavir Yadav 312 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in the confirmation email to activate your subscription. up vote 3 down vote function dateofbirth(source, args) { var dtcDOB =
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/Display a dynamic message with customvalidator - using http://forums.asp.net/t/349096.aspx?Display+a+dynamic+message+with+customvalidator+using+javascript javascript Display a dynamic message with customvalidator - 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 Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply joegass None 0 error message Points 5 Posts Display a dynamic message with customvalidator - using javascript Sep 26, 2003 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 asp.net custom validator was found. Easily done on the server side, just by changing the property, but I'd like to be able to do it 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