use required field validator and set the control to validate in required field validator properties to Your text box name.set validation group of button control and validator control same Give some error message in Text property of validator. if you want use custume validator itself
protected void test(object source, ServerValidateEventArgs args)
// write your test code here
if(textbox.text.trim().Length > 0)
custumvalidatorname.isvalid = flase;
if(args.isvalid)//it will execute only when custum validator is valid
write the code you need
or tool manu
add one custom valiadator from tool box its self.
Hope this helped you sorry less time more work
While shine's method is good and will work fine. He is using the server side code to validate the textbox.
So sorry, I re-read your question and see you want NO whitespaces. I hate doing Expressions, everytime I use them I have to re-read how to write them. Someday I will get it straight. LOL
Ok so here it is fro clientside validating. The first RequiredField Validator checks to see that the textbox is not empty. The RegularExpression Validator checks to see that where are no white spaces between point 0 and point 20. If you look at my textbox you will see that it has a maxlength of 20 so I can only type in a max of 20 letters. I can type in Freon22 and it will validate ok but if I type in Freon 22 it will fail. I can type in a max of 20 letters and it will pass as long as there are no whitespaces between any of the letters or numbers.