Rigix

PHOTO EMBED

Thu Apr 14 2022 19:24:24 GMT+0000 (UTC)

Saved by @anasrathore #kotlin

class MainActivity : AppCompatActivity(), View.OnClickListener {
    //private var txMessage:TextView?=null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


		edEmailAddress.setText("ali@gmail.com")
        edPassword.setText("Ali@1234")

        btnSignIn.setOnClickListener(this)
private fun onSignIn(){
        /*val email = edEmailAddress.text.toString().trim()
        val password = edPassword.text.toString().trim()*/
        val emailRegex = Regex("^[\\w!#\$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#\$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}\$")
        val passwordRegex = Regex("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#&()–[{}]:;',?/*~$^+=<>]).{8,20}$")
        val email = edEmailAddress.getInputText()
        val password = edPassword.getInputText()


        if(email.isNullOrEmpty()){
            showToast("please enter your email address")
            return
        }

        if(!emailRegex.matches(email)){
            showToast("please enter valid email address")
            return
        }

        if(password.isNullOrEmpty()){
            showToast("please enter your password")
            return
        }

        if(!passwordRegex.matches(password)){
            showToast("please enter your password")
            return
        }
content_copyCOPY