function sendForm() {
var formO = document.getElementById(“frm1”);
//reset the textbox values to the encrypted values
var newval1 = encryptStr(document.getElementById(“value1”).value);
var newval2 = encryptStr(document.getElementById(“value2”).value);
window.alert(newval1);
//now submit the form
formO.submit();
}
function encryptStr(str) {
//put your encryption code here
But bear in mind, for the php script to receive the encrypted strings you will have to reset the textbox values in the form to the respective encrypted strings (newval1, newval2) before .submit() as in my previous code.
<script type="text/javascript">
function sendForm() {
var formO = document.getElementById("frm1");
//reset the textbox values to the encrypted values
var newval1 = encryptStr(document.getElementById("value1").value);
var newval2 = encryptStr(document.getElementById("value2").value);
window.alert(newval1);
//now submit the form
//formO.submit(); [COLOR=red]//comment out for testing purposes
[/COLOR]}
function encryptStr(str) {
//put your encryption code here
var strOut = str + [B][COLOR=red]'[/COLOR][/B]abc[B][COLOR=red]'[/COLOR][/B]; // sample Encryption code
return strOut;
}
</script>
var formO = document.getElementById("the_form");
var username_val = document.forms['the_form'].elements["username"].value;
var password_val = document.forms['the_form'].elements["password"].value;
var xor_key='1234';
var username_res="";
var password_res=""
for(i=0;i<username_val.length;++i)
{
username_res+=String.fromCharCode(xor_key^username_val.charCodeAt(i));
}
for(i=0;i<password_val.length;++i)
{
password_res+=String.fromCharCode(xor_key^password_val.charCodeAt(i));
}
// XOR is done
//shifting the username_res to the left by 1 bit
//username_res = username_res << 1;
//shifting the password_res to the left by 1 bit
//password_res = password_res << 1;
//setting the xor'ed and shifted value for submission
document.forms['the_form'].elements["username"].value = username_res;
document.forms['the_form'].elements["password"].value = password_res;
//alert("UserName: " + username_res);
//alert("Password: "+ password_res);
form0.submit();