java中确认密码的代码 java怎样实现密码的输入
java编写一个更改密码校验程序,有两个密码框,一个用于输入新密码,另一个请输入确认密码……
import java.awt.event.ActionEvent;
创新互联主营新和网站建设的网络公司,主营网站建设方案,成都app软件开发,新和h5成都小程序开发搭建,新和网站营销推广欢迎新和等地区企业咨询
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class keyPassword extends JDialog{
private JLabel jl1 = new JLabel("password:");
private JLabel jl2 = new JLabel("确认密码");
private JTextField pwd1 = new JTextField(18);
private JTextField pwd2 = new JTextField(18);
private JButton sure = new JButton("确定");
private JPanel jp1 = new JPanel();
public keyPassword(){
setVisible(true);
setSize(300, 150);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jp1.add(jl1);
jp1.add(pwd1);
jp1.add(jl2);
jp1.add(pwd2);
jp1.add(sure);
sure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String str = pwd1.getText();
String str2 = pwd2.getText();
if(str.equals("") || str2.equals("")){
JOptionPane.showMessageDialog(null, "不能为空");
}else if(str.equals(str2)){
JOptionPane.showMessageDialog(null, "两次密码相同!");
}else{
JOptionPane.showMessageDialog(null, "两次密码不相同!");
}
}
});
add(jp1);
}
public static void main(String[] args) {
new keyPassword();
}
}
最新版本:有什么问题可以联系我,
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class keyPassword extends JDialog{
private JLabel jl1 = new JLabel("password:");
private JLabel jl2 = new JLabel("确认密码");
private JPasswordField jpf = new JPasswordField(18);
private JPasswordField jpf2 = new JPasswordField(18);
private JButton sure = new JButton("确定");
private JPanel jp1 = new JPanel();
public keyPassword(){
setVisible(true);
setSize(300, 150);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jp1.add(jl1);
jp1.add(jpf);
jp1.add(jl2);
jp1.add(jpf2);
jp1.add(sure);
sure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
char[] str_ = jpf.getPassword();
String str=String.copyValueOf(str_);
char[] str2_ = jpf2.getPassword();
String str2 =String.copyValueOf(str2_);
if(str.equals("") || str2.equals("")){
JOptionPane.showMessageDialog(null, "不能为空");
}else if(str.equals(str2)){
JOptionPane.showMessageDialog(null, "两次密码相同!");
}else{
JOptionPane.showMessageDialog(null, "两次密码不相同!");
}
}
});
add(jp1);
}
public static void main(String[] args) {
new keyPassword();
}
}
JavaScript的密码确认代码是什么?
只要用JavaScript判断密码输入和密码确认输入时候一致即可。
table
tr
td valign="middle"div align="right"密码:/div/td
tddiv align="left"
input type="password" name="userpassword" id="userpassword" /span id="error_userpassword"/span/div/td
/tr
tr
td valign="middle"div align="right"密码确认:/div/td
tddiv align="left"
input type="password" name="userpassword_enter" id="userpassword_enter" /span id="error_userpassword_enter"/span/div/td
/tr
/table
script language="javascript1.2"
function vertify_userpassword(){
if (document.getElementById("userpassword").value==""){
document.getElementById("error_userpassword").innerText="请输入密码!";return false;}
else
{document.getElementById("error_userpassword").innerText="";return true}
}
/script
JSP中如何写密码输入和确认密码时正确与否的Java判断代码?
jsp中判断两次输入的密码是否相同的方法是通过js实现的。\x0d\x0a在两个文本框里添加onchange事件,在文本框的内容一发生变化时就触发该事件,而判断就写在这个事件之内就可以了。\x0d\x0a\x0d\x0a \x0d\x0afunction check()\x0d\x0a{\x0d\x0a\x0d\x0aif (document.form1.username.value==""){\x0d\x0aalert("请输入登录账号!");\x0d\x0areturn false;\x0d\x0a}\x0d\x0aif (document.form1.passwords.value==""){\x0d\x0aalert("请输入登录密码!");\x0d\x0areturn false;\x0d\x0a}\x0d\x0aif (document.form1.password.value==""){\x0d\x0aalert("请输入重复密码!");\x0d\x0areturn false;\x0d\x0a}\x0d\x0aif (document.form1.password.value!=document.form1.passwords.value){\x0d\x0aalert("对不起!重复密码不等于登录密码");\x0d\x0areturn false;\x0d\x0a}\x0d\x0a\x0d\x0areturn true; \x0d\x0a\x0d\x0a}\x0d\x0a \x0d\x0a\x0d\x0a
分享题目:java中确认密码的代码 java怎样实现密码的输入
浏览路径:http://azwzsj.com/article/dossejs.html