-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have a datebox with some constraint. When I use lenient="false", it shows a error message box beside the datebox. How can I catch this error and handle it without the default errorbox? (Please give some Java code if possible).
Thanks in Advance
I do something this
<zscript>
void reset(){
username.setValue("");
password.setValue("");
con_password.setValue("");
}
void register(){
String errorMsg = "";
if(username.getValue()==null || username.getValue().trim().equals("")){
errorMsg += "Username cannot be empty!\n";
}
/*if(password.getValue()==null || password.getValue().trim().equals("")){
errorMsg += "Password cannot be empty!\n";
}else*/ if(!password.getValue().equals(con_password.getValue())){
errorMsg += "Passwords do not match!\n";
}
if(!errorMsg.equals("")){
Messagebox.show(errorMsg,"Error",Messagebox.OK,Messagebox.ERROR);
}else {
registerWnd.onRegister();
}
}
</zscript>
<grid>
<zscript><![CDATA[
Constraint ctt = new Constraint() {
public void validate(Component comp, Object value) throws WrongValueException {
org.zkoss.zul.Calendar oggi=new Calendar();
if (oggi.getValue().getYear()-value.getYear()<18)
throw new WrongValueException(comp, "Devi essere maggiorenne");
}
}
]]>
</zscript>
<rows>
<row>Username: <textbox id="username" constraint="no empty"/>*,a-zA-Z,0-9</row>
<row>Password: <textbox id="password" constraint="no empty" type="password"/>*</row>
<row>Confirm Password: <textbox id="con_password" constraint="no empty" type="password"/>*</row>
<row>email: <textbox id="email" width="150px"
constraint="/.+@.+\.+/: Please enter an e-mail address" />*</row>
<row>Birthday: <datebox id="bdate" width="150px" constraint="${ctt}"/>*</row>
<row>
<button label="Reset" onClick="reset()"/>
<button label="Register" onClick="register()"/>
<!-- <button label="Back to Login" onClick="registerWnd.back()"/> -->
</row>
</rows>
</grid>
</window>
Thank you sly3. I implemented a nearly similar solution. Found it in Developer Guide.
Asked: 2009-08-03 14:26:48 +0800
Seen: 228 times
Last updated: Aug 06 '09