r/javaScriptStudyGroup • • Apr 08 '16

JavaScript help

3 Upvotes

I am trying to create a order form and validate it with JavaScript. Nothing happens when I hit the submit button. It is like the js page isnt communicating with the html. Any suggestions?

  <form id="orderForm" action="" onsubmit="validateContactForm()">
        <fieldset>
          <legend>Customer Information</legend>		
		  <table summary="Customer Information">
		    <tr>
              <td><label for="firstName">First name:</label></td>
			  <td><input type="text" name="firstName"/></td>
              <td><label for="lastName">Last name:   </label></td>              
			   <td><input type="text" name="lastName"/></td>
 			</tr>  
			 <tr>
			  <td><label for="email">E-mail address:</label></td>
			  <td><input id="email" type="text" name="email"/></td>
			  <td><label for="socialSecurityNumber">Social Security Number: </label>
			  <td><input type=" submit" name="submit" value=""/></td>
			 </tr>
            <tr>
			  <td><label for="address">Address:</label></td>
			  <td><input id="address" type="textarea" name="address"/></td>
			  <td><label for="city">City:</label></td>
			  <td><input id="city"type="text" name="city"/></td>
			 </tr>
 			<tr>
			  <td><label for="state">State:</label></td>
			  <td><input id="state" type="text" name="state"/></td>
			  <td><label for="zipCode">Zip Code:</label></td>
			  <td><input id="zipCode" type="text" name="zipCode"/></td>
			 </tr>  
          </table>
        </fieldset>
		 <fieldset>
		  <legend>Products</legend>
		  <table summary="products">
		    <tr>
			  <td><label for="products">Select Product:</label></td>
			  <td><select>
		            <option id="" name="Noob">Noob</option>
                    <option id=""name="Level-2">Level 2</option>
                    <option id="" name="Level-3">Level 3</option>
                    <option id="" name="Level-4">Level 4</option>
                    <option id="" name="Level-5">Level 5</option>
                  </select></td>
			</tr>
            <tr>
			  <td><label for="quantity">Quantity (between 1 and 5):</label></td>
              <td><input type="number" name="quantity" min="1" max="5"/></td>
          </table>
	    </fieldset>
		<fieldset>
		  <legend>Complete Order</legend>
		  <table summary="Complete Order">
		   <tr>
		    <td><input type="submit" value="Enter Order"/></td>
			<td align="right"><input type="reset" value="Reset Form"/></td>
		   </tr>
		 </table>
   		</fieldset> 

//orders.js

function validateContactForm() { var orderFormObj = document.getElementById("orderForm"); var firstName = orderFormObj.firstName.value; var lastName = orderFormObj.lastName.value; var email = orderFormObj.email.value; var socialSecurityNumber = orderFormObj.socialSecurityNumber.value; var address = orderFormObj.address.value; var city = orderFormObj.city.value; var state = orderFormObj.state.value; var zipCode = orderFormObj.zipCode.value; var everythingOK = true;

if (!validateName(firstName))
{
 alert("Error: Invalid First Name.");
 everythingOK = false;

}
if (!validateName(lastName))
{
    alert("Error: Invalid last name.");
    everythingOK = false;
}

if (!validateSSN(socialSecurityNumber))
{
    alert("Error: Invalid Social number.");
    everythingOK = false;
}

if (!validateEmail(email))
{
    alert("Error: Invalid e-mail address.");
    everythingOK = false;
}

if (everythingOK)
{
    alert("All the information looks good.\nThank you!");
    return true;
}
else
    return false;

} function validateName(name) { var p = name.search(/[-'\w\s]+$/); if (p == 0) return true; else return false; }

function validatePhone(phone) { var p1 = phone.search(/\d{3}[-\s]{0,1}\d{3}[-\s]{0,1}\d{4}$/); var p2 = phone.search(/\d{3}[-\s]{0,1}\d{4}$/); if (p1 == 0 || p2 == 0) return true; else return false; }

function validateEmail(address) { var p = address.search(/\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})$/); if (p == 0) return true; else return false; }


r/javaScriptStudyGroup • • Jan 14 '18

"this" keyword confuses me

3 Upvotes

Hey all. I have done minimal javascript work in the past and have often run into weird situations with the word this. Sometimes, the compiler tells me to do .bind(this) and other weird things that I just can never really grasp. What is "this"? Why do we use it and how do I use it correctly?


r/javaScriptStudyGroup • • Jan 15 '18

Any Javascript newbies in NYC want to study together in person?

1 Upvotes

Hi Reddit,

I'm self-teaching myself Javascript, and realized that I learn best in an environment where I'm learning around others, in person. Right now I'm using the following tutorial site to teach myself: https://javascript.info/js, as well as various YouTube videos.

I'm comfortable with loops, conditionals, variables, and am looking to take my knowledge to the next level -- learning how to work with different frameworks and libraries. Eventually I plan to learn the entire MERN stack. My goal is ultimately to learn more about the web, and understand how to program for the web/mobile.

Weekends would be ideal, but happy to meet up during the week as well.

Does this sound like something anyone would be interested in? Contact me if interested! Look forward to learning together!


r/javaScriptStudyGroup • • Apr 04 '16

[Week 12] Focus: for...of

4 Upvotes

So here we are at Week 12. Week 12's focus will be for...of.

Background info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of

It will work like this:

  • Monday: Announce focus (eg, for...of)

  • Build throughout the week... Two rules: 1) must use javascript 2) must use at least 1 example of a for..of loop.

  • Friday: Post demos/projects in this thread (can begin reviewing immediately); first line of an entry should be ENTRY and it should be a top level comment (ie, don't put your entry in a reply)

  • Sat and Sun: Review projects/figure out focus for next week

GENERAL GUIDELINES FOR FEEDBACK:

  • Be nice!! ALL KNOWLEDGE/SKILL LEVELS ARE WELCOME AND ENCOURAGED TO PARTICIPATE.

  • If you don't want feedback, if it makes you uncomfortable or you're just not interested, simply say so... Others, please be respectful of this. Conversely, if you do want feedback, try to be specific on which aspects... even if you just say "all/everything.

But that's about it... Have fun! :) Feel free to ask questions and discuss throughout the week!


r/javaScriptStudyGroup • • Apr 10 '16

Midas Gold Plus - bear with me

2 Upvotes

So for the last 2 months I've become hooked on Midas Gold Plus; an idle game on Kongregate.
Midas Gold Plus

This is relevant because I've become known in the community because I made them a skill calculator for part of the game that I've since expanded on several times. The game creators even gave me like $20 of premium currency in recognition :)

Left it on codepen where it has had almost 4k views.
Some of it clearly only makes sense if you dig into the game but leaving it here because, as always, I would welcome any sort of feedback etc. It qualifies as my most relevant / used / purposeful thing I've made and actually got out there :)
Skill Calculator


r/javaScriptStudyGroup • • Mar 28 '16

[Week 11] Focus: ES6 Classes

1 Upvotes

So here we are at Week 11. Week 12's focus will be ES6 classes.

Background info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

It will work like this:

  • Monday: Announce focus (eg, ES6 classes)

  • Build throughout the week... Two rules: 1) must use javascript 2) must use at least 1 example of an ES6 class.

  • Friday: Post demos/projects in this thread (can begin reviewing immediately); first line of an entry should be ENTRY and it should be a top level comment (ie, don't put your entry in a reply)

  • Sat and Sun: Review projects/figure out focus for next week

GENERAL GUIDELINES FOR FEEDBACK:

  • Be nice!! ALL KNOWLEDGE/SKILL LEVELS ARE WELCOME AND ENCOURAGED TO PARTICIPATE.

  • If you don't want feedback, if it makes you uncomfortable or you're just not interested, simply say so... Others, please be respectful of this. Conversely, if you do want feedback, try to be specific on which aspects... even if you just say "all/everything.

But that's about it... Have fun! :) Feel free to ask questions and discuss throughout the week!


r/javaScriptStudyGroup • • Jan 15 '18

Beginner, where to learn next?

2 Upvotes

Hi everyone! I've just started learning JavaScript through CodeCademy. I really find it a good way to self-teach. However, I was wondering what is a good place to further develop my Javascript skills after I finished the course. Hope some of you had any good ideas. Thanks!


r/javaScriptStudyGroup • • Jul 26 '19

ReactJS Best Practices and Libraries

Thumbnail
opencodez.com
5 Upvotes

r/javaScriptStudyGroup • • Dec 08 '19

React Native Animation API - Explained with Examples

Thumbnail
opencodez.com
2 Upvotes

r/javaScriptStudyGroup • • Dec 09 '19

I need help asap plz

1 Upvotes

So... I have a work due for school and since I am trash and all, idk what to do. It's very simple, but I don't know why I can't do it. Basically, I have to do a mini chess game with 5 pieces (2 kings, black queen, black bishop and a black rook). Every time one of the pieces check's the king, an alert is suppose to pop up. When the king can't get away, it's checkmate. All needs to be done on an 8x8 board... Ik I'm bad but plz help meeeeee.


r/javaScriptStudyGroup • • Sep 30 '19

Three Different Ways to Create Objects in JavaScript

Thumbnail
medium.com
2 Upvotes

r/javaScriptStudyGroup • • Sep 30 '19

Build and Deploy a Realtime Chat Application - Socket.io, Node.js, and React.js

4 Upvotes

Hello everyone, I won't rattle on too much, everything is in the title. I created a YouTube video about building a real-time chat application, if you're interested, feel free to take a look. Here's the link - https://youtu.be/ZwFA3YMfkoc.

Any feedback and/or critique is welcomed and appreciated! :)


r/javaScriptStudyGroup • • Apr 30 '18

help needed calculate average with es6 rest operator

1 Upvotes

Hi everyone,

wondering if someone can assist, i have problems comprehending why my code is not working, as part of the udacity nanodegree for front-end track this exercise requires calculating the total of numbers and outputting the average however its not working as required below is my code:

// your code goes here

function average(...nums) { for(var num of nums){ // add together all numbers in the array num += num/2;

}

var total = num/2; console.log(total);

  var [value1] = nums;
  nums += value1;
  console.log(nums);
  return total;

}

// console.log(num); console.log(average(2, 6)); console.log(average(2, 3, 3, 5, 7, 10)); console.log(average(7, 1432, 12, 13, 100));


r/javaScriptStudyGroup • • Jul 31 '19

JavaScript interview prep

5 Upvotes

I have tried to collate most of the questions in this app - https://play.google.com/store/apps/details?id=gamesmint.com.jsone (it is free and there are no ads).

Besides this these links will be very useful for senior position

  1. Large scale JS architecture - https://addyosmani.com/largescalejavascript/ and https://www.youtube.com/watch?v=b5pFv9NB9fs

  2. MVC in native JS - https://alexatnet.com/model-view-controller-mvc-in-javascript/

  3. DS & Algo in JS - https://github.com/trekhleb/javascript-algorithms

  4. Edit - Forgot to add this link https://stackoverflow.com/questions/17718673/how-is-a-promise-defer-library-implemented (promise implementation)


r/javaScriptStudyGroup • • Apr 19 '18

Top 5 mistakes THAT DEVELOPPERS MAKE IN JAVASCRIPT

Thumbnail
youtu.be
7 Upvotes

r/javaScriptStudyGroup • • Aug 14 '18

Advice for Novice

3 Upvotes

Hello, i have completed the HTML and CSS codecademy courses including youtube videos and now have moved onto JavaScript.

I'm finding it hard to take in and undersrand, has anyone got any good advice or tips for me.

Ive bought the book 'Eloquent JavaScript' which states is for beginners but its so complex.

Any help would be gratefully appreciated.

Thank you in advance.


r/javaScriptStudyGroup • • Jul 27 '19

Passing unlimited parameters into JavaScript parameter-less function

Thumbnail
youtu.be
1 Upvotes

r/javaScriptStudyGroup • • Jul 30 '19

ReactJS - React Flux and Redux

Thumbnail
opencodez.com
2 Upvotes

r/javaScriptStudyGroup • • Aug 16 '18

Beginner in JS

1 Upvotes

Hello!

I am a beginner in JS and Programming in general. How would you guys recommend I build a strong foundation? My uni doesn't provide any classes for Js.


r/javaScriptStudyGroup • • Aug 13 '19

JavaScript Project - How to design Countdown Timer in JavaScript Easily - DataFlair

Thumbnail
data-flair.training
4 Upvotes

r/javaScriptStudyGroup • • Oct 17 '19

React Native For Beginners: Tutorial #2 - React Native Props and State

Thumbnail
opencodez.com
1 Upvotes

r/javaScriptStudyGroup • • Feb 24 '20

Need Help with comment section of my website can you please help?

3 Upvotes

I have this website i have the site designed problem is making it to where the comment section where the button is pushed and the date is applied so that the comment is added to the comment section please help me its not a finished site so it needs alot of work. Please i need to know the java script needed to add to make this work?

<!--Leave a Comment Start-->

<section class="leave-comment">

<h2>leave a comment</h2>

<div class="comment-fieldbox">

<form>

<input class="input-name" type="text" name="name" placeholder="Your name \\\*" required />

<input class="input-email" type="text" name="email" placeholder="Your email \\\*" required />

<textarea class="input-textarea" name="comment" placeholder="Comment \\\*" required></textarea>

<div class="comment-active">

<span>All fields are mandatory.</span>

<input class="submit-button" type="submit" value="SUBMIT COMMENT"/>

</div>

</form>

</div>

</section>

<!--Leave a Comment End-->


r/javaScriptStudyGroup • • Mar 20 '19

How to approach system design questions as a Frontend developer?

6 Upvotes

Any suggestions or resources are much appreciated. Thank you 😊


r/javaScriptStudyGroup • • Aug 12 '19

ReactJS - Forms, Events and Keys

1 Upvotes

r/javaScriptStudyGroup • • Aug 13 '19

Places to write your code?

1 Upvotes

I'm new to learning Javascript, but I've known about Javascript for years. I'm curious as to where you guys write your code where its in a text editor, or in the console of a web browser? There are also IDE's, but I'm not certain if that's for testing purposes mainly. I already have ATOM, and running it on a MacBook Pro. Do I have the option of seeing my code working in ATOM, or should I mainly be focused on seeing it in the console? There is also WebStorm, and I'm just divided on which tools to use, and for what.