Valor de UrlDecode en el cuadro de texto html al enviar

I have a very simple form with three fields that I need to submit to an mvc action. The form must be application/x-www-form-urlencoded. however, one of the fields is populated by users copying and pasting an already urlencoded value. I would like to decode that value prior to submitting the form. this seems really simple but I keep running into proplems with my javascript.

Aquí está el código:

function decodeURI()
    <title>Test Create</title>
    <h1> Spoof Profile Calls </h1>
    <div style="border: 1px solid black; width: 300px;">
    <form method="post" action="" name="createprofile">
    <input type="hidden" name="ReturnURL" value="self.close()">
    UserName: <input type="text" name="UserName"><br />
    Client: <input type="text" name="Client"><br />
    URI: <input type="text" name="URI" onblur="decodeURI();"><br />
    <input type="submit" formenctype="application/x-www-form-urlencoded" value="Go To - Create"><br />

The URI field is the one that needs url decoded prior to submission because it gets reencoded and thus corrupted. I could ask the users to un-encode these values themselves but they are not terribly sophisticated users and it will likely not happen.

Gracias de antemano!


preguntado el 04 de diciembre de 12 a las 04:12

Hi you can use, onChange listerner of that textfield and change the value of that textfield using the javascript. -

I tried something like that but received an error saying "cannot read property 'value' or undefined" maybe you could help me with the javascript? -

can you post the code what have you tried / -

1 Respuestas

Reemplazar la línea

URI: <input type="text" name="URI" onblur="decodeURI();"><br />


URI: <input type="text" name="URI" onchange="decodeURI(this);"><br />

Y haz algo como

function decodeURI(elm) {
    elm.value = 'foo ' + elm.value + ' bar';
    return false;

Respondido el 04 de diciembre de 12 a las 05:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.