# submit form

**URL:** <https://www.phphelp.com/t/submit-form/16267>\
**Category:** Javascript & Ajax\
**Created:** [March 17, 2012, 1:47am UTC](https://www.phphelp.com/t/submit-form/16267 "2012-03-17T01:47:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![searls03](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@searls03](https://www.phphelp.com/u/searls03)\
**Post date:** [March 17, 2012, 1:47am UTC](https://www.phphelp.com/t/submit-form/16267/1 "2012-03-17T01:47:11Z")

</div>

so I have a magnetic stripe scanner, I need the form to submit automatically when a certain number of characters is reached in the form field. any help?

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [March 17, 2012, 5:38am UTC](https://www.phphelp.com/t/submit-form/16267/2 "2012-03-17T05:38:53Z")

</div>

Use the ONCHANGE on the field and send it to a javascript function.  
In the function, check the len(ofthefield) and whatever…

---

<div class="post-metadata">

**Author:** ![searls03](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@searls03](https://www.phphelp.com/u/searls03)\
**Post date:** [March 18, 2012, 3:05am UTC](https://www.phphelp.com/t/submit-form/16267/3 "2012-03-18T03:05:54Z")

</div>

So I have this:  
[php]

  
  
  

| \*Card Number: |   
[/php]

the form submits via ajax. how do I make a pup up window that will display a text box that then is part of the form, but the form doesn’t submit until this textfield is filled in. how would I do this?

 |

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [March 20, 2012, 4:43pm UTC](https://www.phphelp.com/t/submit-form/16267/4 "2012-03-20T16:43:41Z")

</div>

Well, do you mean this line:

You already have a function in it that is called “onkeyup” which is name “fun”.  
So, when a key is pressed in this input field and released, this code is called.  
You can just add your pop-up in that function. Something like this would be needed:

```auto
if (card.card1.value.length value.length > 8) {
   // Whatever you want when this field reaches 8 chars... (Change number to your limit)
   alert("Card1 is full!"); // This alert is just a sample... 
  }
```

NOTE: in Javascript the length is formatted: form\_name.textfield\_name.vlaue.length…  
So, card.card1 is your form’s name and text field’s name…

Hope that helps…
