Click here to Skip to main content
16,016,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey there,

i am using some controls which i want to validate with some particular properties.My controls to validate are-

1) txtName -- it should take only alphabets,limit should be upto 40 and is mandatory.

2) txtAddress -- should tale all characters,mandatory and limit 100.

3) txtPhone - should take only integers,No Space and limit 12.

4) ddlSearchItems -- item must be selected(>0) and mandatory.

5) txtQuantity -- should take only integers,mandatory,No Space and limit upto 4 and mandatory.

6) btnSubmit -- should be disabled if datatable(dtValues.rows.count <= null) is null,else enabled.

Thanks
Amit
Posted
Updated 15-Sep-10 18:38pm
v3

Use Validation Controls, it'll fulfill most of your conditions.
For others, use Javascript.
 
Share this answer
 
Comments
AmitChoudhary10 16-Sep-10 0:36am    
which one to use like in txtPhone - no sapce,limit 12 and integers only?..
nagendrathecoder 16-Sep-10 0:42am    
You can use Regular Expression Validator to validate a phone number.
AmitChoudhary10 16-Sep-10 1:02am    
which property in regular expressions is used so that control only takes alphabets or integers?..
nagendrathecoder 16-Sep-10 1:13am    
If you want to validate for only alphabets or integers, don't use Validator.
Design regular expressions for your need and use it.
AmitChoudhary10 16-Sep-10 1:21am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Mandatory fields: use required field validator.
Length: Use maximum length property of text box.
For regular expressions Check here[]
 
Share this answer
 
Comments
AmitChoudhary10 16-Sep-10 0:50am    
And how are hidden fields used to store an error message which is displayed only when user does'nt work according to the validations(error messages are to be displayed)?...
m@dhu 16-Sep-10 0:53am    
set Display="Dynamic" for validation control
AmitChoudhary10 16-Sep-10 1:02am    
which property in regular expressions is used so that control only takes alphabets or integers?..
m@dhu 16-Sep-10 1:15am    
validation expression..
These all are very much basic have a look at this link(validation controls) http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp
AmitChoudhary10 16-Sep-10 1:20am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900