I'm making a validation form with EditText. I have three EditText boxes and I want to make sure the user types something on ed1
before going to ed2
. So, I want to block the user from going to ed2
unless they put something in ed1
. If ed1
is null, the cursor won't go to ed2
. Can someone help me?
final EditText ed1 = (EditText) findViewById(R.id.one);
final EditText ed2 = (EditText) findViewById(R.id.two);
TextWatcher watcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
if (ed1.getText().toString().equals("")) {
ed2.requestFocus();
}
}
};