cancel
Showing results for 
Search instead for 
Did you mean: 

Input Field Validation

Former Member
0 Kudos

Hi all,

I want to validate the form input field .My input field data should be in lowercase otherwise I want to pass an error message.

How can check the case of input field data and pass the message.

Can anybody send link for the web dynpro api documentation link?

Thanks&Regards,

Suresh Kumar T

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

u hav two options

1>U can convert the input data into lowercase irrespective of the input case by using these api's

String input = wdcontext.currentcontextelement.getinput();

input.toLoweCase();

--

2>use simple java code to validate lowercase

--

String s = wdcontext.currentcontextelement.getinput();

for(int i=0;i<s.length();i++){

if(s.charAt(i) >= 'a' && s.charAt(i)<='z');

else

wdcomponentapi.getmessagemanager.reportsuccess("Only lowercase accepted");

}

Answers (2)

Answers (2)

amolgupta
Active Contributor
0 Kudos

hi,

your problem can be solved using simple core Java.

Just study the java.lang.String class.

read your context attribute.

and check for lower case.

regards,

-Ag.

Former Member
0 Kudos

Hi,

Use the java regular expression to compare the values and then through a context exception.

Use the following code in wdDoBeforeNavigation

Pattern p = Pattern.compile("[a-z]");

Matcher m = p.matcher(wdContext.currentContextElement.getText());

boolean b = m.matches();

if(!b)

{

wdComponentAPI.getMessageManager().reportContextAttributeMessage("<attribute>, "<Your message>", "<Params>" );

wdComponentAPI.getMessageManager().cancelNavigation();

}

Regards

Ayyapparaj