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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:30:18+00:00 2026-06-01T12:30:18+00:00

I would like to overwrite the value of the password field before submiting a

  • 0

I would like to overwrite the value of the “password” field before submiting a form on Jquery using AjaxSubmit function.
I know I can just update the value on the input field but, I don’t want the user to see this transformation. In other words, I just want to send a custom value to the password field and keep the current value on the screen…

How could I do that?

My current code:

var loginoptions = { 
    success: mySuccessFuction, 
    dataType: 'json'
}

$('#My_login_form').submit(function(e) {
    e.preventDefault();
    var pass=$("#My_login_form_password").val();
    if (pass.length>0){
        loginoptions.data={
            password: ($.sha1($("#My_login_form_csrf").val()+$.sha1(pass)))
        }
    $("#My_login_form").ajaxSubmit(loginoptions);
    delete loginoptions.data;
});

The problem with this code is that it is sending a “password” POST variable with the form field value and, a duplicated one with the value I set on “loginoptions.data”.

  • 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-01T12:30:19+00:00Added an answer on June 1, 2026 at 12:30 pm

    It seems that ajaxSubmit uses the serialize() function of jquery on the form and then, adds the extra data serialized too. So, if I have a field named “password” with the value “1234” and then try to change that to “abcd”, using “loginoptions.data.password”, it will serialize everything and put the “options.data” like this:

    "password=1234&field_2=value_2&password=abcd"
    

    After many tries, I gave up on using ajaxSubmit function and decided to use ajax function to submit the form:

    var the_form=$('form#My_login_form');
    loginoptions.url=the_form.attr("action");
    loginoptions.type=the_form.attr("method");
    var serializedForm=decodeURIComponent(the_form.serialize());
    loginoptions.data=serializedForm.deserializeToObject();
    var pass=$("#My_login_form_password").val();
        if (pass.length>0){
            loginoptions.data.password= ($.sha1($("#My_login_form_csrf").val()+$.sha1(pass)));
        }
    $.ajax(loginoptions);
    

    Here is the deserializeToObject() function:

    function deserializeToObject (){
        var result = {};
        this.replace(
            new RegExp("([^?=&]+)(=([^&]*))?", "g"),
            function($0, $1, $2, $3) { result[$1] = $3; }
        )
        return result;
    }
    
    String.prototype.deserializeToObject = deserializeToObject;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to override a Javascript built-in function with a new version that
I'm using a RichTextBox (.NET WinForms 3.5) and would like to override some of
I would like to temporarily override the kill-new function. I have a way I
Would like to get a list of advantages and disadvantages of using Stored Procedures.
Would like to create a strong password in C++. Any suggestions? I assume it
i have been reading about a function that can overwrite its return address. void
I am new to jQuery and would like to update an element's id. My
I have a script which can overwrite values in a configuration file using options,
Using Guava, I would like to have a map that has the following properties:
I would simply like to append an additional value which is generated at runtime

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.