Jump to content

Count the Numbers from a field in a web form


foochuck

Recommended Posts

I have a basic text input field on a web form.

 

I want to have my users type in 16 numbers ( it can be any sixteen numbers - as long as the count is 16 numbers exactly - I'm not checking it with a database )

 

Using a post method, the page submits the form to itself.

 

Basically, I'm just wondering how I can tell if 16 numbers have been entered into my field?

 

The field is named fm_id. I'm taking it from the $_POST and creating a variable called $id

 

How can I count the number of numbers in $id ?

 

Thanks

 

FOO

Link to comment
Share on other sites

Have you tried JS.  You can give the users immediate feedback instead of waiting to post to the server for the check.

 

Javascript IS a great way to give the user immediate feedback, however it should NOT be relied upon as the only validation. You must ALWAYS have server-side validation. User can have JS turned off or submit data without using your form.

Link to comment
Share on other sites

Good point mj. Thanks again.

 

Have you tried JS.  You can give the users immediate feedback instead of waiting to post to the server for the check.

 

Javascript IS a great way to give the user immediate feedback, however it should NOT be relied upon as the only validation. You must ALWAYS have server-side validation. User can have JS turned off or submit data without using your form.

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.