cancel
Showing results for 
Search instead for 
Did you mean: 

input should accept only alphabets(validation)

Former Member
0 Kudos

Hi

I have a input field with label EMPLOYEE NAME where it should accept only alphabets spacesand dot(.)For example(k.krishna rao).

Thanks

Krishna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

check the following code it may help you

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

if (fld.charAt(i) == "." || fld.charAt(i) == "/")

{

//Generate code or

wdcomponentAPI.getMessageManager().reportSuccess(....);

}

and for generating Error Messages you can go through the following documentation.

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60db527d-7be4-2a10-0283-e915cfb179a8]

Regards

Raghu

Edited by: Raghunandan Madarikuruva on Oct 17, 2008 11:15 AM

Edited by: Raghunandan Madarikuruva on Oct 17, 2008 11:33 AM

Answers (3)

Answers (3)

Former Member
0 Kudos

chkInput-->String

2)then do the binding.

3)create message in message pool

MessageKey-->inputValidation

MessageType-->error

MessageText-->you have entered ,which is in not alphabet.

Please enter valid .

3)create Method and check for the input field

and implement your method.

your code may look like this.you can do your manipulation according to your requirement.

public void chkInputField( java.lang.String chkInp)

{

//@@begin CheckDate()

IWDMessageManager msgmgr=wdComponentAPI.getMessageManager();

Integer inInt =(Integer)wdContext.currentContextElement().getAttributeValue(chkInput);

IWDAttributeInfo attinfo=wdContext.getNodeInfo().getAttribute(chkInput);

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

if (chkInp.charAt(i) == "." || chkInp.charAt(i) == "/")

{

//show the error message

msgmgr.reportContextAttributeMessage(wdContext.currentContextElement(),

attinfo,

IMessageMainComp.INPUT_INVALID,

new Object[]{ chkInput},

true);

//@@end

}

Former Member
0 Kudos

HI kirshna rao ,

Below is a helpful link for input data validation.

just go threw it.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/837d9290-0201-0010-1381-e633fe17...

Regards.

Punit Singh

former_member192434
Active Contributor
0 Kudos

Hi

Create a context attribut and map that attribut type with Integer and onEnter create a method where you can put the validation.

Take the help of this code.

DecimalFormat pattern = new DecimalFormat( "#,##0;(#,##0)" );

String numberString = "(1,234)";

Number n = null;

try

{

n = pattern.parse( numberString );

}

catch ( ParseException e )

{

//( "oops:" + numberString );

// n = new Integer( 0 );

}

Thanks