glen morris
-
Posts
2 -
Joined
-
Last visited
Posts posted by glen morris
-
-
Hi there. I'm just having some trouble with the chapter 10 forms 'putting it all together' task.
I created the register.js file as guided by the book, which has validation using regular expressions. However, when I load the form in a browser, and try to create some errors by incorrectly filling it in, I just get the generic HTML5 error messages, which say "Please fill out this field". I want the form to validate dynamically using the validateForm() function inside of register.js, not the standard HTML '<required>' validation.
How can I make my form use these regular expression validations to give me the 'inline' errors using <span> which the book refers to on page 415, as opposed to the HTML5 errors?
My code appears to be identical to the book, so I won't put my code in here unless it's necessary?
Thanks
Chapter 10 - Working With Forms Error Messages...
in Modern Javascript: Develop and Design
Posted
Thanks guys! I deleted everything, and re-pasted everything from scratch. To my own shock, It works fine now I spent hours trying to figure it out, haha.
I had another small question related to the same code. I want to change the submit button's text, so that when It's disabled (checkbox unchecked) it says "Disabled" and when it's not disabled (checkbox checked) it says "Submit".
I'm a newbie at this, but I would assume the best way to go about this would be to alter the 'toggleSubmit()' function and add 'innerHTML' to it? I'm not really sure..
HTML:
Javascript: (register.js)
I hope that makes sense? This code is using utilities.js for the event listeners and variables etc.
Thanks again for the prompt replies!