Text box validation using regular expressions

Posted by Sreenuksr under ASP.NET on 10/19/2011 | Points: 10 | Views : 1205 | Status : [Member] | Replies : 2
I have a textbox and have to use the regular expressions in asp.net


my text should not allow the spaces in first and last place.

output should be:
-----------------

India Bangalore -valid

<space>India Bangalore<space> - not valid

i.e : use can enter the spaces in between the words but not in first position and last position.


If you have solution in java script that also fine.

Thanks in advance.




Responses

Posted by: Hmanjarawala on: 10/20/2011 [Member] Bronze | Points: 25

Up
0
Down
i think you need not to put validation for this.....just use trim function whenever you take value from textbox.....spaces will remove automatically...

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Sreenuksr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/20/2011 [Member] Starter | Points: 25

Up
0
Down
I agree with Hmanjarawala,
We can use Trim function instead of wasting time in reg.exp.

Sreenuksr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response