Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jQuery syntax error question

Posted on 2014-12-18
2
Medium Priority
?
141 Views
Last Modified: 2014-12-18
Please look for my comments enclosed within two lines of asterisks:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Form Sample</title>
	<link rel="stylesheet" href="normalize.css" />

<!--[if lt IE 8]>
	<style>
		legend {
			display: block;
			padding: 0;
			padding-top: 30px;
			font-weight: bold;
			font-size: 1.25em;
			color: #FFD98D;
			margin: 0 auto;
		}
	</style>
<![endif]-->

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("form#myform").submit(function() {
			/*********************************************************

                          WHEN THE NEXT IF-STATEMENT IS EXECUTED, IT SAYS:
                          Syntax error, unrecognized expression: input:#myname

                         *********************************************************/
			if (($("input:#myname").val() == "") || 
			   ($("input:#myemail").val() == "") || 
			   ($("input:#myurl").val() == "")) {	
				return false;
			}
			return true;
		});
	});
</script>

</head>
<body>

<form id="myform" class="group" action="thanks.html" method="POST">
	<fieldset id="login" title="Login Info">
		<legend>Login Info</legend>
		<ol>
			<li>
				<label for="myname">Name *</label>
				<input type="text" name="myname" id="myname" title="Please enter your name" autofocus placeholder="Last, First" />
			</li>
			<li>
				<label for="myemail">Email *</label>
				<input type="email" name="myemail" id="myemail" autocomplete="off" />
			</li>
		</ol>
		<div class="buttonnav next">next</div>
	</fieldset>
	<fieldset id="other" class="hidden" title="Other Info">
		<legend>Other</legend>
		<ol>
			<li>
				<label for="myurl">Website *</label>
				<input type="url" name="myurl" id="myurl" />
			</li>
		</ol>
	</fieldset>
	<fieldset id="comments"  class="hidden" title="Comments">
		<button type="submit">send</button>
	</fieldset>
</form>
</body>
</html>

Open in new window


Can someone please tell me what I'm doing wrong? Thanks.
0
Comment
Question by:elepil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40507812
Should be

			if (($("input#myname").val() == "") || 
			   ($("input#myemail").val() == "") || 
			   ($("input#myurl").val() == "")) {	

Open in new window


You don't even need the input bit
0
 

Author Closing Comment

by:elepil
ID: 40507883
This was actually part of an example I got that I was studying. Thanks for your help, Gary.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question