cancel
Showing results for 
Search instead for 
Did you mean: 

Range Validations

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi ayyaparaj,

can u please explain with coding to find length which should not be greater or lesser than10 y becoz iam new to wedyn pro,sorry to trouble u

thanks

kishore

Edited by: kishore shikore on May 28, 2008 8:30 AM

Former Member
0 Kudos

s