I am validating my form using javascript validation as whole validation is working fine but email validation is not working. My form code is as follows  &lt;form method="post" action="contact.php" name="myForm" onsubmit="return validateForm()"&gt;  &lt;h3&gt;To know more contact us today.&lt;/h3&gt;      &lt;table&gt;         &lt;tr&gt;             &lt;td&gt;Name:                 &lt;br /&gt;                 &lt;input id="name" name="name" type="text" /&gt;             &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;Contact No:                 &lt;br /&gt;                 &lt;input id="contact" name="contact" type="text" /&gt;             &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;Email:                 &lt;br /&gt;                 &lt;input id="email" type="text" name="email" /&gt;             &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;Address:                 &lt;br /&gt;                 &lt;textarea cols="34" id="address" name="address" type="text"&gt;&lt;/textarea&gt;             &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;                 &lt;input type="submit" value="Submit" /&gt;             &lt;/td&gt;         &lt;/tr&gt;     &lt;/table&gt; &lt;/form&gt;   and my javascript code is as follows    &lt;script type="text/javascript"&gt;         function validateEmail() {              var emailID = document.["myForm"]["email"].value;             atpos = emailID.indexOf("@");             dotpos = emailID.lastIndexOf(".");             if (atpos &lt; 1 || (dotpos - atpos &lt; 2)) {                 alert("Please enter correct email ID")                 document.myForm.email.focus();                 return false;             }             return (true);         }         function validateForm() {             var x = document.forms["myForm"]["name"].value;             if (x == null || x == "") {                 alert("First name must be filled");                 return false;             }             var x = document.forms["myForm"]["contact"].value;             if (x == null || x == "" || isNaN(document.myForm.contact.value) || document.myForm.contact.value.length != 10) {                 alert("Contact Number Must be 10 Digits");                 return false;             }             var x = document.forms["myForm"]["email"].value;             if (x == null || x == "") {                 alert("Email is must");                 return false;             }             else {                  var ret = validateEmail();                 if (ret == false) {                     return false;                 }             }             var x = document.forms["myForm"]["address"].value;             if (x == null || x == "") {                 alert("Address cannot be empty");                 return false;             }             return (true);         }      &lt;/script&gt;
Is there a regular expression to validate an email address in JavaScript?
Mark a comment as the answer to a question What does functools.wraps do? In a comment on this , someone said that they weren't sure what functools.wraps was doing. So, I'm asking this question so that there will be a record of it on StackOverflow for future reference: what does functools.wraps do, exactly? Using Moq to determine if a method is called It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.:  public abstract class SomeClass() {         public void SomeMehod()     {         SomeOtherMethod();     }      internal abstract void SomeOtherMethod(); }   I want to test that if I call SomeMethod() then I expect that SomeOtherMethod() will be called.   Am I right in thinking this sort of test is available in a mocking framework? Creating files in C++ Is there a phrase that means sleeping with someone without sex? I know that I can update a snap package using  sudo snap refresh &lt;package&gt;   But is there a way to update all snaps, like   sudo apt dist-upgrade Calling Java from MATLAB? var functionName = function() {} vs function functionName() {} We put all of our unit tests in their own projects.  We find that we have to make certain classes public instead of internal just for the unit tests.  Is there anyway to avoid having to do this.  What are the memory implication by making classes public instead of sealed? Can I use my iPhone as a "remote" for my iPad? Equivalent of "both" when referring to three or more items? The supremum norm is submultiplicative Is the following proof correct:  Let $X$ be a compact Hausdorff space and $C(X)$ the space of continuous functions $f: X \to \mathbb{C}$. We can equip $C(X)$ with the (edit: sorry, semi-)norm $\lVert f \rVert_\infty = \sup_{x\in X} |f(x)|.$ I want to prove that for $f,g \in C(X)$, $\lVert fg \rVert_\infty \leq \lVert f \rVert_\infty \lVert g \rVert_\infty $. Let $z \in X$ be arbitrary then $$ \lvert f(z)g(z) \rvert \leq \lvert   \; \sup_{x} \lvert f(x) \rvert  g(z)  \;\rvert=\sup_{x} \lvert f(x) \rvert  \lvert    g(z)\rvert \leq \sup_{x} \lvert f(x) \rvert  \sup_{y} \lvert g(y) \rvert.  $$  Since $z$ was arbitrary $$ \sup_{z} f(z)g(z)\leq \sup_{x} f(x) \sup_{y} g(y) $$  that is the sought. I need to solve $3x^2 + 6x +1 \equiv 0 \pmod {19}$  I saw the same problem here -     but didn't understand how he got to the conclusion   $x(x+2) \equiv 6 \pmod {19}$  and anyway im trying to solve it how we learned in class -   multiply both sides and the modulo by $4a$ then solve the two equations  $y^2 \equiv b^2 -4ac \pmod {4an}$  $2ax + b \equiv y \pmod {4an}$  so I tried multiplying the hole thing by $4a$ , that is $4 \times 3$  and got to $(2 \times 3x + 6)^2 \equiv 36 -4 \times 3 \pmod {19 \times 4 \times 3}$  now I am stuck . any help will be appreciated Calculus Question: $\int_0^1\frac{(x-x^2)^4}{1+x^2}dx$ What is the coefficient of the term $a^i b^j c^k$ in the expansion of $(a+b+c)^n$? What is the coefficient of the term $a^i b^j c^k$  in the expansion of   $(a+b+c)^n$ ?   Given solution:     Before collecting like terms, each term in the expansion is a product   of $n$ factors each  of which is $a, b,$ or $c$.  Those terms which   have exactly i a’s, j b’s and k c’s can be combined into   the single term $a^i b^j c^k$ and the number of such terms will be   equal to the number of n letter strings containing i a’s, j b’s and k   c’s, which by the Mississippi rule is $\frac{n!}{(i!\times j! \times  k!)}$.   I understand that this problem is actually about the derivation of the coefficient of the multinomial theorem,but I am not sure about the combinatoric reasoning,what I mean is that I understand the analogy problem but what I couldn't is how the analogy holds here,Could anybody explain this to me? I'm a bit confused about what Gstreamer does.   Does it come installed by default with Ubuntu ?  If so which version  is the default for 14.04?  Does it provide hardware accelerated video playback (decoding) ?   If so does it work with VA-API and VDPAU or is it an alternative to those?    Thanks for your help Can't connect to Android device My Android device won't connect. I've never got MTP to work, I've only ever got it to connect by USB mass storage, which was how it was working most recently. But now, since 13.04, it seems that option has been taken away entirely.  I need to be able to connect by USB to transfer files.  When I plug in the device I get an error that says Unable to open MTP device '[usb:002,003]':    After some web searching, I found that I might need a program called go-mtpfs, so I tried that, and it failed:  $ go-mtpfs /media/MyAndroid 2013/07/16 16:41:43 compiled against libmtp 1.1.5 Device 0 (VID=04e8 and PID=685e) is a Samsung Galaxy Y. 2013/07/16 16:41:43 found device Samsung: Galaxy Y (04e8:685e) @ bus 2, dev 3 :  LIBMTP PANIC: Unable to find interface &amp; endpoints of device 2013/07/16 16:41:43 rdev.open failed: open: open returned nil   How do I get my USB device to just connect, automatically, like it used to? Is there a video that explains how Stack Overflow works and can be used? Is there a video that explains how Stack Overflow works and can be used? I.e. a short tutorial to get new users started. If there isn't, then the people behind this site or others who know how it works should make one, because it's overwhelmingly different from other sites and thus difficult for beginners. How to parse JSON in Java Find the number of dissimilar terms in the expansion of $$\bigg(x+\frac{1}{x}+x^2+\frac{1}{x^2} \bigg)^{20}$$  Could someone give me some hint to proceed in this question. I used $x+1/x=t$ and wrote expansion as $(t^2+t-2)^{20}$ but even this does not convey much information. Please help.