on 06-23-2008 12:40 PM
Hi
i have a input field with label PIN code which should not be NULL and should accept exactly six digits only and should not even accept Spaces in between, can u tell the required code
Thanks
Durga
Hi
First check the null
if not call the below method
Use the following method
public boolean isAllNumeric( java.lang.String stringValue )
{
//@@begin isAllNumeric()
boolean isNumeric = false;
isNumeric = Pattern.matches("0-9+", stringValue);
return isNumeric;
//@@end
}
which gives you whether the value is numeric or not.if not throw an error
if yes find the length of the string if not equals 6 throw an error.
Also you can restrict the input field to 6 digits by writing this code in init method.
use try catch block
ISimpleTypeModifiable homeAddrPostalCode = wdContext.wdGetAPI().getModifiableTypeOf ("HomeAddData<nodename>.PostalCode<attribute>");
homeAddrPostalCode.setMaxExternalLength(6);
Regards
Kalyan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
make an attribute of type long and name it as pin. I am creating it in
in wdDoModifyView()
the Root context
IWDAttributeInfo info = wdContext.getNodeInfo().getAttribute("Pin");
info.getModifiableSimpleType().setFormat("######");
in the OnAction() where you are validating, put this code
if(wdContext.currentContextElement().getPin() == 0 ) {
//display empty error message
}
else {
String temp = Long.toString(wdContext.currentContextElement().getPin());
if(temp.length >6 )
// display limit exceeds error message
} // if (temp)
}//else
nikhil
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 to validate Pin Number Input.
String pin = wdContext.current<node>Element().getPinNo() ;
if(pin.length != 6 ){
wdComponentAPI.getMessageManager().reportException("Invalid Pin No." , true);
}
Mandeep Virk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The following code should help you with your requirements.
if(wdContext.currentContextElement().getMobileNo().length()==6)//For calculating length.
{
int valid_flag=1;
for(int i=0;i<6;i++)
{
int j = wdContext.currentContextElement().getMobileNo().charAt(i);
if(j >=48 && j<=57)
{
valid_flag=1;
}
else
{
valid_flag=2 ;
break;
}
}
if(valid_flag==2)
{
wdComponentAPI.getMessageManager().reportSuccess("Please Enter a valid password");
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("Valid password");
}
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("Please Enter a valid password");
}
Regards,
Sudeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Durga,
The input field for which you are entering null, try to read the value form the context of the corresponding field.
After reading this value store this in any String variable and validate,i.e:-
String strVal = wdontext.currentContextElement.getName();
IWDMessageManager messageManager = wdComponentAPI.getMessageManager();
if(strVal.equalsIgnoreCase(null)){
/// print the error msg
messageManager .reportException(("error msg",true);
}
else{
///----needed code
}
Hope that may help you.
Regards,
Deepak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.