表单里有“密码”和“确认密码”两个字段,当我输入“确认密码”时,怎样才能验证其与“密码”一致呢?
我想要的效果就是当“确认密码”和“密码”不相同时,“确认密码”输入框旁边会出现一个错误提示!
GWT-EXT如何验证字段呢?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- sptzone 2008-09-24 09:40关注
[code="java"]VerticalPanel vp = new VerticalPanel();
vp.add(title); vp.add(description); final PasswordTextBox pbox1 = new PasswordTextBox(); final PasswordTextBox pbox2 = new PasswordTextBox(); final Label label = new Label(); VerticalPanel panel = new VerticalPanel (); FlowPanel topPanel = new FlowPanel(); FlowPanel bottomPanel = new FlowPanel(); panel.add(topPanel); panel.add(bottomPanel); topPanel.add(pbox1); bottomPanel.add(pbox2); bottomPanel.add(label); pbox1.addFocusListener(new FocusListener() { public void onFocus(Widget sender) { } public void onLostFocus(Widget sender) { if(!pbox1.getText().equals(pbox2.getText())) { label.setText("password is not same!"); } else { label.setText(""); } } }); RootPanel.get().add(panel);[/code]
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报