careful-holiday-81711
02/20/2023, 9:02 PMtall-chef-86788
02/21/2023, 6:04 AMhtmx
land.. ( I have a background in `react`/`typescript` + `svelte`/`typescript` )
I was doing username checkup in real time. For example a user can check if the username is taken up by other users during sign up process.
But in any case i have found out a way ( thanks :D )tall-chef-86788
02/21/2023, 6:08 AMhtml
{% extends 'user/base.html' %}
<!--prettier-ignore-->
{% block title %} Sign Up {% endblock title %}
<!--prettier-ignore-->
{% load crispy_forms_tags static %}
{% block form %}
<form method="post" action="{% url 'signup_view' %}">
<div class="flex justify-center mb-10">
<div class="font-bold text-4xl select-none flex">
<span class="inline-flex text-white">c</span>
<span class="inline-flex text-warning">o</span>
<span class="inline-flex text-white">r</span>
<span class="inline-flex text-white">e</span>
Â
<span class="inline-flex text-info">p</span>
<span class="inline-flex text-info">r</span>
<span class="inline-flex text-info">o</span>
<span class="inline-flex text-info">j</span>
<span class="inline-flex text-info">e</span>
<span class="inline-flex text-info">c</span>
<span class="inline-flex text-info">t</span>
</div>
</div>
<div class="grid gap-6">
{% crispy form %}
<div class="flex justify-center items-center gap-2">
<button
class="btn btn-secondary font-bold text-black"
type="submit"
>
Register
</button>
or
<a class="underline" href="{% url 'login_view' %}" hx-boost="true"
>login</a
>
</div>
</div>
</form>
<!--This is the problem code block-->
<script>
let el = document.querySelector('#id_username');
el.addEventListener('input', async () => {
});
</script>
{% endblock %}
tall-chef-86788
02/21/2023, 6:09 AMtall-chef-86788
02/21/2023, 6:09 AMhtmx
2.0.0
i will face this issue again )
Maybe clear out the JS stack somehow ?
---
Python code used for rendering :
python
#forms.py
class RegisterForm(forms.Form):
username = forms.CharField(
widget=forms.TextInput(
attrs={
"placeholder": "Username",
}
)
)
email = forms.EmailField(
widget=forms.TextInput(
attrs={
"placeholder": "Email",
}
)
)
password = forms.CharField(
widget=forms.PasswordInput(
attrs={
"placeholder": "Password",
"autocomplete": "new-password",
}
)
)
confirm_password = forms.CharField(
widget=forms.PasswordInput(
attrs={
"placeholder": "Confirm Password",
"autocomplete": "new-password",
}
)
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_show_labels = False
# https://stackoverflow.com/a/29717314
for visible in self.visible_fields():
# Add tailwind classes
visible.field.widget.attrs[
"class"
] = "input w-full text-white font-semibold max-w-xs border-[3px] border-warning focus:outline-0"
visible.field.widget.attrs["style"] = "--tw-bg-opacity: 0.3"
tall-chef-86788
02/21/2023, 7:24 AMtall-chef-86788
02/21/2023, 7:27 AMjs
var el;
el ??= document.querySelector('#id_username');
tall-chef-86788
02/21/2023, 7:27 AMflaky-fish-46395
02/21/2023, 11:16 AMmammoth-family-48524
02/21/2023, 12:03 PMmammoth-family-48524
02/21/2023, 12:03 PMflaky-fish-46395
02/21/2023, 12:33 PMeager-psychiatrist-68229
02/21/2023, 2:27 PMeager-psychiatrist-68229
02/21/2023, 2:28 PMeager-psychiatrist-68229
02/21/2023, 2:29 PMeager-psychiatrist-68229
02/21/2023, 2:29 PMflaky-fish-46395
02/21/2023, 2:34 PMeager-psychiatrist-68229
02/21/2023, 2:34 PMeager-psychiatrist-68229
02/21/2023, 2:36 PMeager-psychiatrist-68229
02/21/2023, 2:36 PMflaky-fish-46395
02/21/2023, 2:42 PMeager-psychiatrist-68229
02/21/2023, 2:42 PMeager-psychiatrist-68229
02/21/2023, 2:43 PMeager-psychiatrist-68229
02/21/2023, 2:43 PMflaky-fish-46395
02/21/2023, 2:52 PMeager-psychiatrist-68229
02/21/2023, 2:53 PMcareful-holiday-81711
02/21/2023, 2:56 PMeager-psychiatrist-68229
02/21/2023, 2:58 PMeager-psychiatrist-68229
02/21/2023, 2:58 PMcareful-holiday-81711
02/21/2023, 3:00 PM