Sign Up

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

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

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

Sign Up Here
Continue with Google
or use

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.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

JavaScript

This category lists all questions and answers related to the Javascript programming language.

Share
  • Facebook
2 Followers
14 Answers
58 Questions
Home/JavaScript/Page 2
  • Recent Questions
  • Answers
  • No Answers
  1. Asked: April 30, 2017In: JavaScript

    How to validate email address in JavaScript?

    Googler
    Googler Explorer
    Added an answer on April 1, 2018 at 9:02 pm

    Using regular expressions is probably the best way. You can see a bunch of tests here (taken from chromium) [code]function validateEmail(email) { var re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}Read more

    Using regular expressions is probably the best way. You can see a bunch of tests here (taken from chromium)

    [code]function validateEmail(email) {
    var re = /^(([^<>()[]\.,;:s@”]+(.[^<>()[]\.,;:s@”]+)*)|(“.+”))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
    return re.test(String(email).toLowerCase());[/code]
    }

    Here’s the example of regular expresion that accepts unicode:

    [code]var re = /^(([^<>()[].,;:s@”]+(.[^<>()[].,;:s@”]+)*)|(“.+”))@(([^<>()[].,;:s@”]+.)+[^<>()[].,;:s@”]{2,})$/i;[/code]

    But keep in mind that one should not rely only upon JavaScript validation. JavaScript can easily be disabled. This should be validated on the server side as well.

    [code]function validateEmail(email) {
    var re = /^(([^<>()[]\.,;:s@”]+(.[^<>()[]\.,;:s@”]+)*)|(“.+”))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
    }[/code]

    [code]
    function validate() {
    var $result = $(“#result”);
    var email = $(“#email”).val();
    $result.text(“”);

    if (validateEmail(email)) {
    $result.text(email + ” is valid :)”);
    $result.css(“color”, “green”);
    } else {
    $result.text(email + ” is not valid :(“);
    $result.css(“color”, “red”);
    }
    return false;
    }

    $(“#validate”).bind(“click”, validate);[/code]

    [code]<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script>

    <form>
    <p>Enter an email address:</p>
    <input id=’email’>
    <button type=’submit’ id=’validate’>Validate!</button>
    </form>

    <h2 id=’result’></h2>[/code]

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: July 16, 2017In: JavaScript

    How to to prevent other event handlers from executing after a certain event is fired ?

    Alan
    Alan Explorer
    Added an answer on January 7, 2018 at 9:01 pm

    return false from within a jQuery event handler is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return falRead more

    return false from within a jQuery event handler is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.

    e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return false will do both. Note that this behaviour differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up

    Source: John Resig

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: March 25, 2017In: JavaScript

    How do i redirect user from page to another in JavaScript ?

    Hassan AbdElrahman
    Best Answer
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 8:57 pm

    Hi Saly, Actually you can achieve this by simulate HTTP redirect by using one of the following : // similar behavior as an HTTP redirect [code]window.location.replace("http://www.oraask.com");[/code] or // similar behavior as clicking on a link [code]window.location.href("http://www.oraask.com");[/cRead more

    Hi Saly,

    Actually you can achieve this by simulate HTTP redirect by using one of the following :

    // similar behavior as an HTTP redirect

    [code]window.location.replace(“http://www.oraask.com”);[/code]

    or

    // similar behavior as clicking on a link

    [code]window.location.href(“http://www.oraask.com”);[/code]

    at the end this your choice but for my suggestion i prefer using  (window.location.replace) because this doesn’t keep originate page in the session history.

    hope this help.

     

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
1 2

Sidebar

Adv 250x250

Explore

  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Footer

Oraask

About

Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy
  • Terms & Conditions

Follow

Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

© 2019 Oraask. All Rights Reserved
With Love by Oraask.