Jump to content

[SOLVED] Form and enter key


stockton

Recommended Posts

I have created an HTML form that contains an input type text field coded as:-

<input type=text name="CardNumber" id="CardNumber" onBlur="sendRequest('.$ClientData.",".$Event.',this.value)">

 

This calls an Ajax script that populates the rest of the HTML form.

 

This fields event is currently activated, in Firefox, via the TAB but the user has requested that the activation be altered to Enter.

 

The problem I have is that Enter is the default action for the form and I cannot think of a way to achieve what the user requires.

 

This means that not only do I want to "Prevent Enter From Submitting Form" but also cause enter to call Ajax.

In Ajax I can then

if (windows.event.keyCode != 13) return; or similar.

 

What I have done so far is alter the HTML FORM line to:-

<form name = 'TicketIssue' id='TicketIssue' method='get' onSubmit='return false;'>

which appears to have stopped the form submitting on Enter and I have added:-

if (window.event.keyCode != 13)

    {

    window.event.keyCode = 0;

    return;

    }

to my sendRequest() in my Ajax. This, however, appears to do nothing for me.

 

In Firebug on my :-

if (window.event.keyCode != 13))

 

I get :-

 

window.event has no properties

http://10.0.0.3/Events/js/ajax.js

Line 39

 

Suggestions please.

 

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.