微信小程序 > 微信公开课 > JAVA设计一个用户注册的小程序
微信小程序,微信公开课,JAVA设计一个用户注册的小程序

JAVA设计一个用户注册的小程序

2019-03-12 17:01:43

微信公开课小程序热门讨论「JAVA设计一个用户注册的小程序」最新回复-OK!这个不难,我去上自习,回来给你答案不好意思,昨天晚上回来一时忘了,下面是源码:importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;publicclassRegisterextendsJFrameimplementsActionListener{JLabelname,password,repassword,age,email,address,zip,ID;JTextFieldtname,tage,temail,taddress,tzip,tID;JPasswordFieldtpassword,trepassword;JButtonOK,cancel;publicstaticvoidmain(String[]args){newRegister();}publicRegister(){JPanelp=newJPanel(newGridLayout(9,2));name=newJLabel(姓名:,JLabel.CENTER);tname=newJTextField(8);p.add(name);p.add(tname);password=newJLabel(密码:,JLabel.CENTER);tpassword=newJPasswordField(16);p.add(password);p.add(tpassword);repassword=newJLabel(确认密码:,JLabel.CENTER);trepassword=newJPasswordField(16);p.add(repassword);p.add(trepassword);age=newJLabel(年龄:,JLabel.CENTER);tage=newJTextField(4);p.add(age);p.add(tage);email=newJLabel(电子邮件:,JLabel.CENTER);temail=newJTextField(35);p.add(email);p.add(temail);address=newJLabel(地址:,JLabel.CENTER);taddress=newJTextField(50);p.add(address);p.add(taddress);zip=newJLabel(邮编:,JLabel.CENTER);tzip=newJTextField(10);p.add(zip);p.add(tzip);ID=newJLabel(身份证号码:,JLabel.CENTER);tID=newJTextField(18);p.add(ID);p.add(tID);OK=newJButton(注册);cancel=newJButton(取消);p.add(OK);p.add(cancel);OK.addActionListener(this);cancel.addActionListener(this);setContentPane(p);setTitle(注册);setBounds(100,100,150,400);setVisible(true);}publicbooleancheckPassword(){Strings1=newString(tpassword.getPassword());Strings2=newString(trepassword.getPassword());if(s1.equals(s2))returntrue;elsereturnfalse;}publicbooleancheckEmail(){Strings=temail.getText();if(s.contains(@))returntrue;elsereturnfalse;}publicbooleancheckID(){Stringid=tID.getText();if(id.length()==15||id.length()==18)returntrue;elsereturnfalse;}publicvoidactionPerformed(ActionEvente){JButtonb=(JButton)e.getSource();if(b==OK){if(checkID()&&checkEmail()&&checkPassword()){JOptionPane.showMessageDialog(this,恭喜你,注册成功!);}else{booleanb1=checkPassword();booleanb2=checkEmail();booleanb3=checkID();if(!b1){JOptionPane.showMessageDialog(this,两次输入密码不一致);}if(!b2){JOptionPane.showMessageDialog(this,电子邮件格式不正确);}if(!b3){JOptionPane.showMessageDialog(this,身份证号码位数必须为15或18);}clear();}}if(b==cancel){clear();}}publicvoidclear(){tname.setText();tpassword.setText();trepassword.setText();tage.setText();temail.setText();taddress.setText();tzip.setText();tID.setText();}}
下面是HTML代码:htmlscriptlanguage=javascriptfunctionon_submit(){//验证数据的合法性if(form1.username.value==){alert(用户名不能为空,请输入用户名!);form1.username.focus();returnfalse;}if(form1.userpassword.value==){alert(用户密码不能为空,请输入密码!);form1.userpassword.focus();returnfalse;}if(form1.reuserpassword.value==){alert(用户确认密码不能为空,请输入密码!);form1.reuserpassword.focus();returnfalse;}if(form1.userpassword.value!=form1.reuserpassword.value){alert(密码与确认密码不同!);form1.userpassword.focus();returnfalse;}if(!(form1.idnumber.value.length==15)&&!(form1.idnumber.value.length==18)){alert(身份证输入有误,请重新输入!);form1.idnumber.focus();returnfalse;}if(form1.ema.value.length==0){alert(请输入E-mail地址!);form1.ema.focus();returnfalse;}if(form1.ema.value.length!=0){for(i=0;iform1.ema.value.length;i++)if(form1.ema.value.charAt(i)==@)break;if(i==form1.ema.value.length){alert(非法E-Mail地址!);form1.ema.focus();returnfalse;}}else{alert(请输入E-mail!);form1.ema.focus();returnfalse;}}/scriptheadmetahttp-equiv=Content-Typecontent=text/html;charset=gb2312title新用户注册/title/headbodyformmethod=POSTaction=regist.jspname=form1onsubmit=returnon_submit()新用户注册brbr用户名(*):inputtype=textname=usernamesize=20br密   码(*):inputtype=passwordname=userpasswordsize=20br再输一次密码(*):inputtype=passwordname=reuserpasswordsize=20br性别:inputtype=radiovalue=男checkedname=sex男inputtype=radioname=sexvalue=女女br出生年月:inputname=yearsize=4maxlength=4年selectname=monthoptionvalue=1selected1/optionoptionvalue=22/optionoptionvalue=33/optionoptionvalue=44/optionoptionvalue=55/optionoptionvalue=66/optionoptionvalue=77/optionoptionvalue=88/optionoptionvalue=99/optionoptionvalue=1010/optionoptionvalue=1111/optionoptionvalue=1212/option/select月inputname=daysize=3maxlength=4日br身份证号:inputtype=textname=idnumbersize=20br电子邮箱:(*)inputname=emamaxlength=28br家庭住址:inputtype=textname=addresssize=20brinputtype=submitvalue=提交name=B1inputtype=resetvalue=全部重写name=B2br/form/body/html运行结果如下图: 更多有关「JAVA设计一个用户注册的小程序」的疑问请扫码关注微信公开课+小程序!
标签:微信公开课,小程序
微信小程序,微信公开课,JAVA设计一个用户注册的小程序

「JAVA设计一个用户注册的小程序」热议话题订阅

方法1:微信扫描微信公开课小程序码即可订阅热议话题「JAVA设计一个用户注册的小程序」

方法2:微信搜索微信公开课小程序名称进入,即可订阅热议话题「JAVA设计一个用户注册的小程序」

方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热议话题「JAVA设计一个用户注册的小程序」

微信公开课小程序热议话题「JAVA设计一个用户注册的小程序」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。

微信公开课热议话题「JAVA设计一个用户注册的小程序」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。