Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:28:36+00:00 2026-05-27T14:28:36+00:00

Im creating a HTML5 form, unfortunately the placeholder property does not work in IE9.

  • 0

Im creating a HTML5 form, unfortunately the placeholder property does not work in IE9. Modernizr helped me solve, but the problem wiht Modernizr is that creates placeholder property as an input value, this limits me to validate that the fields are empty.

To solve the validation, i created the following code:

$(".button").click(function(){
  var reEmail = /^[A-Za-z0-9][a-zA-Z0-9._-][A-Za-z0-9]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  var email = $("#email");
  var name = $("#name");
  if (name.val()=="Name [Required]" && name.val()==""){
     name.val("");
     name.focus();
  } else if (email.val()=="Email [Required]" && email.val()==""){
     email.val("");
     email.focus();
  } else if (!reEmail.test(email)){
      email.val("");
      email.focus();
  } else{
      alert("Thanks!");
  }
});

But this does not work even if the email is correct

Note: sorry for my English and my JS code, I’m still learning 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:28:37+00:00Added an answer on May 27, 2026 at 2:28 pm

    There are several problems with your code.

    flynfish already identified the 2 most important ones :).

    Errors:

    1. name is placeholder *OR* is empty and not name is placeholder *AND* is empty

    2. change (!reEmail.test(email)) to (!reEmail.test(email.val())) to check value

    3. Your regular expression allows ., _ and - only as a 2nd character. You are also not escaping . so it means any character and not only a dot. Also escape - because JSLint/JSHint hates when it is unescaped :).

    Optimizations:

    1. You don’t have to check if email is placeholder or empty string, because those two incorrect values won’t pass the regexp test.

    2. Don’t hardcode placeholder values in the JS code. You can access the placeholder value by using name.attr('placeholder'). That way if you change the placeholder text you don’t have to modify JavaScript.

    3. I would suggest using new <input type="email"> element and using Moderznir with any of the html5 forms polyfils supporting email input. That will make your job a lot easier. You are already using moderznizr and polyfills for placeholder, so check if it doesn’t support also email inputs validation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a jquery ajax popup comment form, but am having a problem
I'm creating an html5 JS form library. The idea is to turn elements with
I am trying my hand at creating an HTML5 form styled with CSS3. However,
I am creating an HTML form with some radio button options. I'd like to
In an HTML form post what are valid characters for creating a multipart boundary?
I am creating a select box for a form using this in _form.html.erb <%=
I am creating a form in HTML that will be printed, with fields that
I am creating a regex library to work with HTML (I'll post it on
I am creating an HTML contact form that uses a standard image for a
I am creating a form with AJAX. The way I have created the form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.