on 05-14-2007 8:30 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
The simplest would be to create a value attribute of type integer .
Automatic validation would take place in this case.
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.