on 05-19-2009 12:33 PM
Hello friends,
I want to validate one input amount field... for that input field the user should not enter characters...If he enter characters then error message should come....
Also give some tutorials for doing this type validation....
Hi Murali,
I don't feel, you need to add some special code for validating, whether an input field is entered characters, just bind the input field to a context of type integer. Use the UI element "Message Area". Whenever, the user will enter some character / string type value, an automatic error message, sting "Value <value entered by the user> contains non-numeric characters", will be displayed.
I hope this solves your issue, if you are looking for something else, please revert. I'll be happy to help you.
Cheers!!!
Umang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello murali,
For validating an input field against non numeric data, You have two ways .
1. You can bind the onput field to a context attribute of type integer or decimal.
This will give a error message automatically from the framework when the user has entered non
numeric data.But the problem with this method is your navigation is cancelled until you enter the
correct value in the input field.So if this validation is done on second screen of the application it will
not allow the user to even navigate to first screen where the validation is not required. So for solving
this problem we can use the other method.
2. Second Method is you write a utility function and validate the input on event you want this validation
to be done. You can use the following code for this.
//
public boolean IsNotNumeric( java.lang.String Input_String )
{
//@@begin IsNotNumeric()
//@@begin IsNotNumeric()
// check for valid numeric strings
String strValidChars = "0123456789-";
char strChar;
boolean blnResult = false;
//Check whether the String is numeric
for (int i = 0; i < Input_String.length() && blnResult == false; i++) {
strChar = Input_String.charAt(i);
if (strValidChars.indexOf(strChar) == -1) {
blnResult = true;
}
}
return blnResult;
//@@end
}
Hope it solves your problem
Regards,
Sarbjeet Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Murali,
I don't feel, you need some special coding for this. What you need to do, just bind the input field to an attribute if type integer. When ever the user will enter a non-integer value and press a button for processing, an error message will be displayed "Value <Value Entered by the user> contains non-numeric characters".
I hope this solves your issue, if you are looking for something else, please revert. I'll be happy to help you.
Cheers!!!
Umang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
check for PATTERN MATCHING code from the google and use that code ,
you can write the code in your action method , or there is another option ,
check the Ascii value for A-Z and a-z and put the if condition , so the you can enter only
numeric values
check this threads
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Murali,
To validate in WD for Java u may use the API IWDMessageManager and its functions for displaying the Error message.
Either u can store the message in the Message Pool and use it or u can directly enter the Error Message in the MessageManager class.
The Syntax is :
1. WdComponentAPI.getMessageManager.reportMessage(<Message>,cancelNavigation(boolean)); or
2. WdComponentAPI.getMessageManager.reportContextAttributeMessager(<CurrentNodeElement>,<AttributeInfoObject>,<MessagePoolObject>,<Object(String for Message)>,<cancelNavigation>);
The First option could be used for displaying the Message, whereas the second option is used when u need to highlight the field which is errenous
Regards,
Poojith M V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Murali,
You can bind the Inputfield to a context attribute of type string ...get the value of the string in the wdDoModifyView() method....and check the ascii value of the characters in the string using <stringname>.charAt(index) function and IWDMessageManager to display the message .....
Hope it helps.
Shikhil
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.