INNER CODE UNIT · Kotlin

beforeTextChanged

Keyspace-cloud/android · app/src/main/kotlin/cloud/keyspace/android/AddCard.kt:336

            override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { }
            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
                if (toDate.text?.length == 2) {
                    try {
                        toDate.text!!.append("/")
                        if (toDate.text?.take(2).toString().toInt() !in 1..12) {
                            toDate.text!!.clear()
                            toDate.error = "Please enter a valid expiry month"
                        }
                    } catch (backspace: java.lang.NumberFormatException) {
                        toDate.text!!.clear()
                    }
                }
            }
        })

        securityCode = findViewById (R.id.CVVInput)
        cardholderNameInput = findViewById (R.id.CardholderInput)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…