变更邮寄表格 [英] Change post form

查看:97
本文介绍了变更邮寄表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有简单的登录表格.在给定的要求下,该密码一定不能发送到服务器,而只能发送到MD5哈希.我使用了简单的MD5功能,现在,当使用onClick on Submit按钮时,我将隐藏文本从密码更改为md5(password).这可以正常工作,但用户看到使用密码的事情正在发生.我想使其透明,并使用onPost(或类似的方法)回调动态更改表单的这一特定部分.

I have simple login form in my website. In given requirements stands, that password mustn't been sent to server, but only MD5 hash. I took simple MD5 function and now, when with onClick on submit button I change hidden text from password to md5(password). This works fine, but user sees, that something with his password is happening. I would like to make it transparent and change this particular part of form dynamically with onPost (or smth like this) callback.

我找不到任何教程来处理javascript中的POST表/表单(jquery?),因此,如果有人可以帮忙,我将不胜感激.

I can't find any tutorials how to deal with manipulating POST table/form in javascript (jquery?) so if anyone could help I would appreciate.

推荐答案

据我所知,没有name的输入字段不会提交到服务器.因此,您可以拥有一个隐藏字段,并在表单的onsubmit事件中通过应用MD5校验和将密码字段的值复制到该隐藏字段中:

As far as I know input fields that don't have name don't get submitted to the server. So you could have a hidden field and in the onsubmit event of the form copy the value of the password field into the hidden field by applying the MD5 checksum:

<form method="post" action="/login">
    <input type="password" id="password" />
    <input type="hidden" name="password" id="hiddenpassword" />
    <input type="submit" value="Login" />
</form>

然后:

$('form').submit(function() {
    var password = $('#password').val();
    var md5 = MD5(password);
    $('#hiddenpassword').val(md5);
    return true;
});

这篇关于变更邮寄表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆