PDA

View Full Version : Restricting invalid value in textbox


learner
07-16-2002, 03:37 AM
Hi,

I have a textbox.Maxlength is only 3 characters.It allows only numeric values.ie from 0-9.

I have restricted all other characters.But the problem is if the user enters 01 or 010 ,similarly 02 or 020 till 9.It enters in the database as 1 or 2 Which i should not allow as the same value will be stored.

For the first time if the user enters 1 and saves into the database,then again he cannot save 1.But if he enters value as above 01 or 010 it is allowing.What could be done.

Is there any way using javascript to avoid that.




Thanks
learner

glenngv
07-16-2002, 04:42 AM
it can be done in javascript but also by HTML alone by setting maxlength to 1 since you only allow nos 0-9

learner
07-16-2002, 11:39 AM
Hi Glenn,


I think i have not explained properly.The textbox can accept not more than 3 characters.ie maxlenth=3.So how can i achieve the above stated requirement using javascript


Thanks

learner

learner
07-18-2002, 03:35 AM
Hi,

I have to restrict the user from entering values in the textbox

like 010,020,030 and so on till 090.Similarly 001,002 and so on till 009.He can only enter values from 0-9 in the textbox(ie 0,1,2,3...9).I have restricted other characters, and special characters from entering but how to restrict him rom entering these values 010,020,030 and so on till 090.Similarly 001,002 and so on till 009.Only these set of values i should not allw him to enter.If he enters i have to validate and give him an alert message.


Thanks

learner

glenngv
07-22-2002, 12:46 AM
can you give me a sample of a valid input which has 3 characters?

Originally posted by learner
Hi,

I have to restrict the user from entering values in the textbox

like 010,020,030 and so on till 090.Similarly 001,002 and so on till 009.He can only enter values from 0-9 in the textbox(ie 0,1,2,3...9).I have restricted other characters, and special characters from entering but how to restrict him rom entering these values 010,020,030 and so on till 090.Similarly 001,002 and so on till 009.Only these set of values i should not allw him to enter.If he enters i have to validate and give him an alert message.


Thanks

learner