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 9156851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:52:11+00:00 2026-06-17T12:52:11+00:00

I am trying jQuery validate. My code is: jQuery.validator.addMethod(isOnlyEmail, function(value, element,param) { var emailVal;

  • 0

I am trying jQuery validate. My code is:

jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { 
  var emailVal;
    $.getJSON('get/getAllData.php?operation=email&email='+value, null, function(data) {
       alert(data);
       if(data==0)
          emailVal true;
       else
          emailVal false;
    });
    return emailVal;
  }, "My message");

I want to display my message, if only return value is true. but this code is wrong. My message is displayed continuously.

if I change my code as follows:

jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { 

        return false;

      }, "My message");

my message is displayed.

if I change my code as follows:

jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { 

            return true;

          }, "My message");

my message is not displayed.

Any idea?

HTML code:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/jquery.js"><\/script>')</script>
        <script language="javascript" type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>

        <!-- Bootstrap jQuery plugins compiled and minified -->
        <script type="text/javascript" src="./js/jquery.validate.js"></script>
        <script>
            $(document).ready(function(){

                jQuery.validator.addMethod("isOnlyEmail", function(value, element,param) { 
                    var emailVal;

                    $.getJSON('get/getAllData.php?operation=email&email='+value, null, function(data) {
                        alert(data);
                        if(data==0)
                            emailVal true;
                        else
                            emailVal false;
                    });
                    return emailVal;
                }, "My Message");

                $("#signupform").validate({
                    rules:{
                        email:"isOnlyEmail"
                    },

                    highlight: function(label) {
                        $(label).closest('.control-group').removeClass('success');
                        $(label).closest('.control-group').addClass('error');
                    },
                success: function(label) {
                    label
                    .text('OK!').addClass('valid')
                    .closest('.control-group').removeClass('error')
                    .closest('.control-group').addClass('success');
                }
            });
        });
        </script>

    </head>
    <body>
        <input id="email" type="email" name="email" placeholder="email@site.com" />
    </body>
</html>

PHP Code:

<?php

    require_once("../db/dbconnect.php");

    $operation = $_GET['operation'];

    if($operation == "email"){

        $mail=$_GET['email'];
        $query = "SELECT * FROM ACCOUNT WHERE email='".$mail."'";
        $result = execute_query($query);
        echo mysql_num_rows($result);
    }
 ?>
  • 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-06-17T12:52:12+00:00Added an answer on June 17, 2026 at 12:52 pm

    my problem is solved.

    I change my code as follows:

    jQuery.validator.addMethod("isOnlyEmail", function(value, element) { 
       var emailVal=true;
       $.ajax({
           url: 'get/getAllData.php?operation=email&email='+value,
           type:'GET',
           dataType: 'json',
           async: false,
           success: function (data) {
                if(data==0)
                   emailVal=true;
                else
                   emailVal=false;
                },
    
            });   
       return emailVal;
    }, "My Message");
    

    Normally, ajax call is run asynchronous mode. There is due to the asynchronous mode, it does not work. If “async: false” is added in my code, the problem is solved.

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

Sidebar

Related Questions

I am trying to get jquery validate to work on multiple fields. Reason being
I am trying to get a simple ignore working for the JQuery validate and
i am trying to validate a form text box using jquery validator, it works
I'm trying to get the height of the error container when using 'jquery validate'
I am using jQuery Validator to validate user input. I am trying to figure
I am trying to using a jquery.validate.unotrusive.js plugin to dynamically created form fields like:
I am trying to validate a form with the jquery-validate plugin. The html page
My issue here is quite simple : i'm trying to use the jQuery validate
I'm trying to validate a input field with the JQuery validation plugin. The numeric
i'm trying to validate an html page using jquery, but nothing happens. it's a

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.