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

View Entire Topic
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