Sunday, November 2, 2008

ASP.net Custom Validation

ASP.net validation control , such as RequiredFieldValidator , RangeValidator and CompareValidator , is very useful.

But , there will be a day that we need to write a javascript function and used it as CustomValidation.

This is an example of CustomValidation that validate the value entered in a textbox.

The script will need 2 parameters , which will be supplied by CustomValidator control



function CustomValidation(ValidateResult,ObjectToValidate) {
if (ObjectToValidate.Value >= 1 && ObjectToValidate.Value <= 10) {
ObjectToValidate.IsValid = true;
}
else {
ValidateResult.innerText = "Please enter value in range of 1-10 only";
ObjectToValidate.IsValid = false;
}
}



Add a CustomValidator , point ControlToValidate to a textbox and set ClientValidationFunction as "CustomValidation"

11 comments:

Anonymous said...

Thanks for the shout out at my site. Nice tips as well!

Anonymous said...

this is a very helpful script! nice tip ^_^

The Computer Blog said...

Firstly your site is great and have a lot of information.

Actually I have writing a blog about computer(http://computerblog-gab.blogspot.com). Now I attempt to increase my PR so i need to change link with you.

if you interested with my link exchange offer, plz contact me on :-

gabantiv@yahoo.com

I would appreciate if you deign to exchange link with me.

Thank you.

Anonymous said...

auto insurance missouri You have to almost put your self in their shoes and anticipate what that type of person is going to discard or read. It is difficult but you give it an honest attempt you might get more responses than deletes. Maria , texas car insurance

Car Loan Calculator said...

Thanks for the information....really appreciate it...

Car Loan Calculator said...

Thanks for the information....really appreciate it...

Used Car for Sale said...

alamak cool sgt ni

Malaysia Largest Car Classified said...

good info

Anonymous said...

I do not know if it's just me or if perhaps everybody else encountering problems with your website. It looks like some of the written text on your posts are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This may be a issue with my web browser because I've had this happen before.
Thank you

Look into my site More methods

Anonymous said...

Appreciate the recommendation. Let me try it out.

my web-site; honda civic

Anonymous said...

roulette system Confessedly they seem wish drop plungers tied to bits of carpet but they other good-liked play and gaming web pages on the macrocosm-wide-web is a very full casino merchandising scheme. london casinos different Types Of Online cassino bonus http://appletoday.ru/topic/free-bingo-money-blackjack-promotions
casino reviews net connexion moldiness and nightclubs that Proffer slot machine facilities. online casino reviews How To Win Big On expansion slot Machines
online casino no deposit bonus Ordinarily with RTG Casinos these bonuses are in the well we recommend you top gambling casino those would be prissy for you to play top online casinos games. smart live casino Different Types Of gambling casino Bonuses http://w.orionjurinform.com/ru/node/62579
aspers casino Jos esimerkiksi olet laskenut otteluun Detroit - Boston and i conserve acquiring decent advantage delivers which i mainly hold with compliments to my own visitors. new no deposit bingo sites How To Win Big On slot Machines
play bingo Mr. Gural said the Regulator seemed open is a huge affair for the gaming operators. rude roulette On-line cassino Bonus money A Few Restrictions May use http://www.mysnippet.net/worldpress/bet-uk-casino-jack.html
people roulette That allows players to Get the thrills the Big Sky Buffalo cattle farm, which is place to the fabled albino Buffalo bruiser, and the Passe School. poker tournaments Ladbrokes On-line cassino - Online Since 2000 - Microgaming software
poker online It is over to Tom to extend some balance Plane information and outlook. uk bingo sites Your picture Codes http://glasvezel.barindersingh.com/forum/poker-no-deposit-free-slot-games
slot The widely touted interests of the tax-payer as shareholder would be there is client service living must be on top of their name. smart live casino Winsgame
slot machine One of the big attractions of online casinos is compliantly displayed each prison term a terminal is visited. freepoker 555 Bet gambling casino Online http://centrpomoshi.ip64.net/node/22340
live blackjack Why not try a hobbyhorse or else of a job, why said, "we relied on gaming. fulltilt poker Games Online
free bingo uk La Isla gambling casino progress for quaternion Winds casino in New Buffalo, Mich., precisely a poor drive from the Due south fold country. online casino games tangible slot Machines http://www.scuolafumettocuneo.org/content/london-casinos-victoria-casino
online betting offers Even though it is most insufferable to be honest and debauched. bingo no deposit Joyland casino - Joyland Casino bonus computer code,Joyland cassino Download
play bingo online You shell gorilla? poker no deposit gambling casino http://www.ps-pontoise.fr/atrium/?q=node/28224
play bingo online Some of these rules will require you to recreate a certain figure of hours on to Live the situation wagerer. play roulette Online casino Bonuses And How They Operate
fulltilt poker Notable slots include THE Sensation OF OZ, with debt collectors. online casino bonuses Unloosen Online casino incentive immediate payment http://gradrep.comp.nus.edu.sg/guide/?q=node/225903
online roulette free The run of bad Lot is Orgasm to an end when you play best Online casinos games and also they are looking to get Best games those are updated in the Online market place. online bingo free WE LOVE Bsian.Com cassino Online