Jump to content

$_GET, Pre-stripping


tsilenzio

Recommended Posts

I have a form.. and after u press submit it submits values to the $_GET variable and the URL.. Well I was wondering if its possible to change the data AFTER the user clicks Submit.. but BEFORE the values actually get submited to the URL..

 

Basickly I want to strip coma's, and $'s from the textbox so in the URL it dosnt come up as %23 or what have u...

Link to comment
Share on other sites

Javascript onsubmit action would be better

 

PHP can't adjust the query string for say on the load but you could fix the get VARS up and then header redirect with the fixed up (sorta sloppy)

 

If you want a neat url maybe you should look int processing with POST unless your form needs GET for caching reasons

Link to comment
Share on other sites

<script language="Javascript">
function chex(id){
var val = document.getElementById(id).value;
var newval = val.replace(/,/g,'');
var finished = newval.replace(/\$/gi,'');

document.getElementById(id).value = finished;
}
</script>

<form method="get" onSubmit="chex('txt');chex('txt2')">
<input type="text" name="txt" id="txt"><br>
<input type="text" name="txt2" id="txt2">
<input type="submit"></form>

 

tested and worked fine.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.