on 05-28-2008 7:09 AM
hi
i have a input field with label mobile no. and user should enter only 10 digits if he enters more or less than 10 digits or if he enters characters that input field should not accept it . please
explain code neatly.
thanks
kishore
Hi,
U need to create a string type attribute and bind it to a input field.
On Enter or on ur Submit button u can write following code.
I create a Attribute of string type say mobileno.
if(wdContext.currentContextElement().getMobileno().length()==10)//For calculating length.
{
int k=2;
for(int i=0;i<10;i++)//For valid mobile no(0-9)
{
int j = wdContext.currentContextElement().getMobileno().charAt(i);
if(j>=48 && j<=57)
{
k=1;
}
else
{
k=2 ;
}
}
if(k==2)
{
wdComponentAPI.getMessageManager().reportSuccess("Please Enter a valid number");
}
else
{
//any custom code when no is valid
}
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("Please Enter a valid number");
}
Regards
Surender
Edited by: Surender Dahiya on May 28, 2008 8:12 AM
Edited by: Surender Dahiya on May 28, 2008 8:50 AM
Edited by: Surender Dahiya on May 28, 2008 8:55 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use one of the following
Create a calculated attribute of type integer(so that characters are not entered.
then in the set method check if the length is greater than 10.
Else
Create a calculated attribute of type sting and use the pattern to match your requirement
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.