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

  • Home
  • SEARCH
  • 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 8592671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:48:22+00:00 2026-06-11T23:48:22+00:00

guys I have a situation here. Im trying to validate an input from user

  • 0

guys I have a situation here. Im trying to validate an input from user that if the input is != "" it will do what inside the if and if its else it will do what inside the else. the validation is quite working except for one thing. though the condition is false it is still going inside the if condition and refreshing the the whole system by using this code $(location).attr('href','account_setting_registrar.php');

can you help me?

        $(document).ready(function (){
         var username ;
         var eadd;

$('#change_usrname_button').click(function (){
    username = $('#new_chnge_username').val();      

            if(username != "" ){
                    $.ajax({
                        type: 'POST',
                        url: 'account_setting_registrar_get.php',
                        dataType: 'json',
                        data:'username='+username,
                        success: function (data){


                                   if(data.error == false){

                                    alert("your username is successfuly changed");

                                       $(location).attr('href','account_setting_registrar.php');
                                   }
                                   else{
                                    alert("update error");
                                 }
                       }  
                    });

                }

                else{
                   alert("please put the new username");
                 }


});



            $('#change_eadd_button').click(function (){


                eadd = $('#new_chnge_eadd').val();


                if(eadd != "" ){
                        $.ajax({
                            type: 'POST',
                            url: 'account_setting_registrar_get.php',
                            dataType: 'json',
                            data:'emailadd='+eadd,
                            success: function (data){

                               if(data.error == false){

                                alert("your email address is successfuly changed");
                                $(location).attr('href','account_setting_registrar.php');
                               }

                               else{
                                alert("update error");
                               }

                             }
                        });
                 }

                 else{
                   alert("please put the new username");
                 }



        });

            });
  • 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-11T23:48:23+00:00Added an answer on June 11, 2026 at 11:48 pm

    I’m thinking your validation should be a little more thorough…

    You are only checking for empty string, however you also don’t want it to be valid if the username is null or undefined as well.

    You’re validation should be the following:

    if (username) {
     // ajax
    }
    

    This will check the following:

    • null
    • undefined
    • NaN
    • empty string (“”)
    • 0
    • false
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation: I have a predetermined GPS route that the user will run.
Here is the situation, I have one input box and one text area on
Ok Guys, here's the situation I have. I'm using a UITableViewController with Core Data.
Okay, here's my situation. I have a WPF app that I have created that
HI Guys I Have A jar File Named Column Reader. I am trying to
I currently have two interfaces(that I'll name here IA and IB ): interface IA
Hey guys. I have the following situation. I want to use a TypeDescriptor to
Guys I've a situation here, I've a HTTP handler ( InsertMap.ashx ) to save
Here's the situation: I've got some lengthy non-UI code that needs to be run
Hi guys I have to model the following situation. I came up with 2

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.