Pls Help on TextBox keypress and .live and ONchange!!

General discussions related to php

Moderators: macek, egami, gesf

mesekarome
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Mar 05, 2012 5:04 pm

Pls Help on TextBox keypress and .live and ONchange!!

Postby mesekarome » Tue Sep 25, 2012 9:29 pm

Hi guys,,


im having a problem with this text box..

the txtbox should type less than 12 characters.. im dont have any problem with keypress..
im having trouble on when the user Click on the virtual keyboard... the text box is not recognizing the keypress..
please help me..
the input number or char must be 12 only.. when click or type on keyboard..
(either by selecting it with their mouse or by pressing the enter key)
thanks

i used onchange, .live.. :help:
but it doesnt work on the textbox.

szalek01
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Sep 27, 2012 2:58 pm

Re: Pls Help on TextBox keypress and .live and ONchange!!

Postby szalek01 » Thu Sep 27, 2012 3:02 pm

You can try use setInterval(function(){checkMyTexBox()},30);

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Pls Help on TextBox keypress and .live and ONchange!!

Postby seandisanti » Mon Oct 01, 2012 2:46 pm

You can also just set maxlength on the input, and then truncate the value before you use it....

with this example you can see how even though i've given the field a default value longer than the 3 character maxlength, it ignores the excess if you don't change it, and won't let you re-enter a 4th character if you edit the text box.

Code: Select all

<?php
   if(! isset($_POST['submit'])) { //not responding to submit ?>
<form action="trystuff.php" method="post" name="example">
   <input type="text" name="foo" maxlength=3 value="bart"/>
   <input type="submit" name="submit" value="checkit">
</form>
<?php
   } else { //handle submitted data:
   echo 'foo:'.substr($_POST['foo'],0,3);
   }
   


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest