label {
float: left;
width: 110px;
}
form div {
padding-bottom: 5px;
}
.error {
color: red;
}
JavaScript
/* hw3b.js */
/*-------------------------------------------------------------------------------------------------
FORM VALIDATION ... javascript representation of this form using the DOM
-------------------------------------------------------------------------------------------------*/
// constructor to just get the first form on the page [0]
//this is the javascript Form object
var Form = function(obj){
//this is the dom object
this.form = obj.form || document.forms[0];
//see the key value pairs and elements in the console
//console.log(this.form.elements);
// create an array of errors to keep track of them
this.errors = [];
// call the prototype that calls the Listener Even submit
this.init();
};
// Event Listener
Form.prototype.init = function(){
/* Scoping fix issue:
// change this to that fixes the scoping issue for this inside the event listener
// otherwise 'this' in the submit context is referring to the form DOM object
// we want 'this.uname' or 'that.uname' to be associated with the javascript object form
// so that we can keep using it in the other functions
*/
var that = this;
this.form.addEventListener("submit", function(event){
//console.log("submitted");
// So in the init in the event listenter: As soon as submit is hit it grabs all of thes values
//this.uname = this.form.elements["username"].value;
that.uname = this.elements["username"].value;
//that.pwd1 = this.elements["pwd1"].value;
//that.pwd2 = this.elements["pwd2"].value;
that.bio = this.elements["bio"].value;
that.firstSelect = this.elements["firstSelect"].value;
that.secondSelect = this.elements["secondSelect"].value;
that.address = this.elements["address"].value;
that.city = this.elements["city"].value;
that.state = this.elements["state"].value;
that.zip = this.elements["zip"].value;
that.phone =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.