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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:01:26+00:00 2026-06-06T19:01:26+00:00

My purpose is user enter only email or mobile number. I have the partial

  • 0

My purpose is user enter only email or mobile number. I have the partial success in that code notify user in OR logic

but… if user want to give both details to me email & mobile no. and entered that info incorrectly then he/she will notified for that to current the data.

<form action="index.php" method="post">
    <label for="email">Your E-Mail Address *</label>
       <input id="UserEmail" type="text" name="email" maxlength="80" size="30"/>
            </p><p>
             Or   
             </p><p>
    <label for="mobile">Mobile Number *</label>
     <input id="mobile" type="text" name="mobile" maxlength="50" size="30" /></p>

below is jquery code

var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal = $("#UserEmail").val();

// email & mobile input cheak
if(emailaddressVal == '' && $("#mobile").val() == '') {
    $("#UserEmail").after('<p><span class="error">Please enter your email address.</span></p>')
    $("#mobile").after('<p><span class="error">Please enter your Mobile number.</span></p>')
    hasError = true;
}  
// validating currect email
else if(!emailReg.test(emailaddressVal)) {
    $("#UserEmail").after('<p><span class="error">Enter a valid email address.</span></p>') 
    hasError = true;
} 
// Mobile number
else if( $("#mobile").val()) {
    $("#mobile").after('<p><span class="error">Enter currect Mobile number.</span></p>')
    hasError = true;
}
  • 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-06T19:01:27+00:00Added an answer on June 6, 2026 at 7:01 pm

    Solution is here

        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        var mobileReg =  /^\d\d\d\d\d\d\d\d\d\d$/m;
        var emailaddressVal = $("#UserEmail").val();
        var mobileval = $("#mobile").val();
    
       //state chk both blank if yes alert
       //OR logic 0-0 
        if(emailaddressVal == '' && mobileval == '') {
            $("#UserEmail").after('<p><span class="error blurry">Please enter your email address.</span></p>')
            .effect("shake", { times:3 }, 20); console.log("email");
            $("#mobile").after('<p><span class="error blurry">Please enter your Mobile number.</span></p>')
            .effect("shake", { times:3 }, 20); console.log("mobile");
            hasError = true;
        }
    
        //chk mobile have value but not email
        //OR logic 1-0 
        else if(!mobileReg.test(mobileval) && emailaddressVal == '') {
            $("#mobile").after('<p><span class="error blurry">Enter currect Mobile number.</span></p>')
            .effect("shake", { times:3 }, 20);console.log("currect mobile");
             hasError = true;
        }
        //chk mobile dont hv the value but email have
        //OR logic 0-1 
        if(!emailReg.test(emailaddressVal) && mobileval == '') {
            $("#UserEmail").after('<p><span class="error blurry">Enter a valid email address.</span></p>')
            .effect("shake", { times:3 }, 20); console.log("valid email");
    
            hasError = true;
    
    
        }
        //chk the input mobile & email have value
        //OR logic 1-1 
        else        
        if(!emailReg.test(emailaddressVal) &&!mobileReg.test(mobileval)) {
            $("#UserEmail").after('<p><span class="error blurry">Enter a valid email address.</span></p>')
            .effect("shake", { times:3 }, 20); console.log("valid email combination");
    
            $("#mobile").after('<p><span class="error blurry">Enter currect Mobile number.</span></p>')
            .effect("shake", { times:3 }, 20);console.log("currect mobile combination");
    
            hasError = true;
    
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modal view that with a UITextView, and the user can enter
I have a user who registered on my website with some email and password.
I have a reference/lookup table whose main purpose is to provide the user with
We have an ASP.NET custom control that lets users enter HTML (similar to a
I have a website that allows to enter HTML through a TinyMCE rich editor
I have a number of C# software applications that are add-ins for a peice
How to make script very interactive? Script purpose: Get user entered number and find
I'd like to make a program that can enter login credentials for authentication purpose
we have an app that has a specific purpose where an exit is required.
User Controls -- Do they serve a special purpose? As far as I can

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.