cancel
Showing results for 
Search instead for 
Did you mean: 

validation on numerical values in webdynpro

Former Member
0 Kudos

Hi Friends,

I am facing one probelem with validation on numerical values. In my application there is a scenario.. Input fields are Mibile number and email id.

when i enter the invalid phone number like : 09988wertyy it should throw the error like enter only numerical values.

In the same way i should validate the email id with format .. like ratnakar.alwala@ accenture.com. if it is in valid then it should throw the error.

could any body please give me the approach.

Thanks and Regards

Ratnakar reddy alwala

Accepted Solutions (1)

Accepted Solutions (1)

former_member186016
Active Contributor
0 Kudos

Hi,

For the phone number problem: You must have binded the input field to some attribute having simple type of type non-string (most probably int,long).

Check the simple type to which you attribute is of. Make the simple type of type string.

Regards,

Ashwani Kr Sharma

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi ,

The simplest would be to create a value attribute of type integer .

Automatic validation would take place in this case.

Regards

Bharathwaj

Former Member
0 Kudos

Yes but the fact is we don't want automatic validation for numeric fields, we want to custom validate ourselves, and the checkbox for disabling validation on actions seems not be working since it validates anyways.

I want to show an error message in spanish/portuguese/whatever, not the default dynpro message.

Edit: As an option.. is there any way to modify those default validation messages?

Regards.

Julio C. Herrera

null

Former Member
0 Kudos

Hi Ratnakar,

For number validation, what I did was :

1. Bind a context variable (Say Number) of type String to the input Field

2. At the time of submission, do the following

String num=wdContext.xurrentContextElement().getNumber();

if(num!=null)

{

try

{

double num=new Double(amnt.trim()).doubleValue();

}

catch(NumberFormatException exc)//IF AMOUNT ENTERED IS NOT VALID

{

wdComponentAPI.getMessageManager().reportException("Invalid Number",true);

}

}

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi,

Try this one..

strPhNo = wdContext.currentContextElement().getCtx_Phno();

if((strPhNo != null) && (strPhNo .length() != 0))

{

blnValidDecimal = wdThis.validateBigDecimal(strNoOfChildren);

}

bgPhNo = new BigDecimal(strPhNo );

wdContext.currentContextElement().setCtx_BigDecimalPhNo(bgPhno);

I hope this code will work for Numeric Ckeck.

Lik this u can keep the logic foe second one.

Reagrds,

Lavanya.G

Former Member
0 Kudos

Ratnakar,

Please check my blog <a href="/people/valery.silaev/blog/2005/11/29/800format-your-way">(800)FORMAT-YOUR-WAY</a>. It contains almost exact answer, the only difference is concrete patterns to format/validate input. I.e. for both your attributes you should use String, format for number is <b>\d+</b> or <b>\d</b> (where 8 bp number of allowed digigts, format of email could be found on web.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net