-3

I've got two input forms:

<input id="name" class="input" name="name" type="text" value="" size="30" />
<input id="email" class="input" name="email" type="text" value="" size="30"/>

this first input (name) shouldn't accept empty field or the many spaces, and the second input (email) should contain only one (@) and at least one dot(.)

Sanjeev Singh
  • 3,976
  • 3
  • 33
  • 38
  • 1
    And what's your question? – k4l4m May 07 '15 at 17:18
  • Your tag only shows "javascript" though this can be done in just HTML5. Please show us what you've tried. – Steve Hynding May 07 '15 at 17:20
  • You're asking for very basic and well-documented form validation. Answers to your question will be widely available via a search engine or SO. – Adam Kewley May 07 '15 at 17:20
  • possible duplicate of [Validate email address in JavaScript?](http://stackoverflow.com/questions/46155/validate-email-address-in-javascript) – Paul May 07 '15 at 17:32

2 Answers2

1

According to my understanding, you are trying to write a form that needs to validate an email address input. If I am right, then you need to validate the email input in javascript. See the code HERE.

JS function to validate email with regex that I used in the jsFiddle demo:

function validateEmail(email) {     
  var re =/\S+@\S+\.\S+/;
  return re.test(email);
}
Zach Young
  • 10,137
  • 4
  • 32
  • 53
The Guest
  • 698
  • 11
  • 27
  • will you include some instructions from that link in this post? This answer, as is, is pretty close to a "link only" answer. From, http://stackoverflow.com/help/how-to-answer, >Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. – Zach Young May 07 '15 at 18:27
0

you can try it with HTML 5

<input id="email" class="input" name="email" value="" size="30" type="email" required />
meOn
  • 194
  • 1
  • 12