I think I would write the check function like this.
check
<script> let pass = "" let is_valid_length let is_valid_case let is_valid_special const invalid_word_regex = /[\s<>]/g const check_case_regex = /(?=.*[a-z])(?=.*[A-Z])/ const check_special_regex = /\W/ $: { pass = pass.replace(invalid_word_regex, "") is_valid_length = pass.length >= 8 is_valid_case = check_case_regex.test(pass) is_valid_special = check_special_regex.test(pass) } </script> <style> .valid { color: green } </style> <input bind:value={pass}> <span class:valid={is_valid_length}>+8</span> <span class:valid={is_valid_case}>a..Z</span> <span class:valid={is_valid_special}>~&#</span>
Totally valid way of using regex :-)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think I would write the
checkfunction like this.Totally valid way of using regex :-)