mercredi 25 novembre 2015

use jquery string in form GET mehtod

i am trying to replace characters using jquery and i want to pass it into a form action get method. Right now i an getting the value of a text field and sending it to the get method. I want to check and replace the a character in the string and then pass it afterwards.. How do i do that?

my code:

    <li>
        <form action="Citizen/CitizenSearch" method="get">
            <input class="cpr-search" type="text" name="cpr" />
            <input class="cpr-search" name="submit" type="hidden" value="Søg" />
        </form>
    </li>
<script type="text/javascript">
    $('#Søg').keypress(function (e) {
        var cpr = $('#cpr').val();
        if (cpr.indexOf("-") >= 0) {
            cpr = cpr.replace("-", "");
        }
        if (e.which == 13) {
            $(this).blur();
            $('#submit').focus().click();
        }
    });
</script>

i am very new to mvc and web development.. can anyone help ?

Aucun commentaire:

Enregistrer un commentaire