密碼驗證我想在此添加密碼驗證,但在得到它得到的問題,我希望有一個密碼模式其中包括一些ATLEAST (number of characters, special characters, lowercase letters, uppercase letters
) 這種模式。但我無法實現這一點,請幫助。如何實現機器人
我使用過Android Studio
public class SignUp extends MainActivity {
private EditText et_name, et_email, et_password, et_cpassword;
private String name, email, password, cpassword;
Button signupbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_up_form);
et_name = (EditText) findViewById(R.id.name);
et_email = (EditText) findViewById(R.id.Email);
et_password = (EditText) findViewById(R.id.Password);
et_cpassword = (EditText) findViewById(R.id.Confirm_Password);
signupbtn = (Button) findViewById(R.id.Signbtn);
signupbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
register();
}
});
}
public void register() {
initialise();
if (!validate()) {
Toast.makeText(this, "Sign up Failed", Toast.LENGTH_SHORT).show();
} else {
onSignUpSuccess();
}
}
public void onSignUpSuccess() {
Intent intent = new Intent(SignUp.this, HomePage.class);
startActivity(intent);
finish();
}
public boolean validate() {
boolean valid = true;
if (name.isEmpty() || name.length() > 32) {
et_name.setError("please enter valid name");
valid = false;
}
if (email.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
et_email.setError("please enter valid Email");
valid = false;
}
if (password.isEmpty())
et_password.setError("please enter a valid password");
return valid;
}
public void initialise(){
name = et_name.getText().toString().trim();
email = et_email.getText().toString().trim();
password = et_password.getText().toString().trim();
cpassword = et_cpassword.getText().toString().trim();
}
}
不知道如果這兩個選項幫助,但看看那些:https://docs.djangoproject.com/en/1.11/topics/signals/(如JS中的事件)和https://docs.python.org/2/library/io.html – oneturkmen
以最初的想法實時獲取數據需要一個XMLHTTP請求,使用vanilla javascript可能會產生問題,因爲每個瀏覽器都有自己的如何創建XMLHTTP請求的「想法」。 – Raptus