Set Required field validation in swift

func validationTextfield() -> String{
        if(txtEmail.text? .isEmpty)!{
            txtEmail.becomeFirstResponder()
            return "Please enter email"
        }else if(txtPassword.text? .isEmpty)!{
            txtPassword.becomeFirstResponder()
            return "Please enter password"
        }
        return ""
    }
@IBAction func btnTapLogin(_ sender: Any) {
        let str = validationTextfield()
        if str == "" {
            //write your code
            
        }else{
            //Display required field dialogue
        }
    }