4

I'm currently making an HTML registration form that completely relies on AJAX and JavaScript (no libraries please), also using MDL.

My problem is that I want to validate the email and the username real-time, i. e. onBlur the AJAX makes a call to the server asking whether the email and the username are taken. If yes, I want to mark the inputs as invalid and display a textfield error saying what happened. This, however, doesn't seem to be possible using MDL.

What I tried: use customValidity(), but MDL only realises the change after a keydown, so this doesn't work. I also tired assigning the input divs an is-invalid class, but same problem as before.

What I need: override the validity from JS and trigger MDL into realising that the validity changed and should update elements accordingly.

Is this possible?

km6
  • 2,191
  • 2
  • 15
  • 18

0 Answers0