cancel
Showing results for 
Search instead for 
Did you mean: 

validate input field

Former Member
0 Kudos

Hi

i have a input fied with label AMOUNT the end user should enter only numeric values(123.67) should not allow any other values like alphabets

Thanks

raju

Accepted Solutions (1)

Accepted Solutions (1)

former_member192434
Active Contributor
0 Kudos

Hi Raju,

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

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Go through the following link a good PDF on Validating input form

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

Regards

Raghu

Former Member
0 Kudos

hi!

1)create a context variablecontext

chkInput-->integer

2)then do the binding.

3)create message in message pool

MessageKey-->intinput

MessageType-->error

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

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 chkInt)

{

//@@begin CheckDate()

IWDMessageManager msgmgr=wdComponentAPI.getMessageManager();

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

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

//give your if condition for whatever restriction you want to give

//show the error message

msgmgr.reportContextAttributeMessage(wdContext.currentContextElement(),

attinfo,

IMessageMainComp.INPUT_INVALID,

new Object[]{ chkInput},

true);

//@@end

}

siddharth_jain
Active Contributor
0 Kudos

Hi

Try creating an simple type of type integer.

Assign this ta Context Value attribute.

Bind it to the Input field.

Corrections:

Create a simple type of Built-in type Float in Local dictionary so that it can accept both int and float values.

When you will click a button then WD Validation Framework will automatically validate the input and dispaly the error message,

Also your Button Action event handler should be created with Without Validation option unchecked.

Siddharth

Edited by: Siddharth Jain on Oct 17, 2008 11:28 AM