Welcome Guest, Not a member yet? Register   Sign In
How to give restriction value in input type text
#1

[eluser]tashigiri[/eluser]
hello all..

Im beginner with web development and now have a problem..
My problem is :

i have "data value(int), input type text and button" , and when i want to input, the data what i want to input is no more than data value(int) that i have.
Example :
data value(int) = 90
when i want to input, the data should no more 90. then when i click button i want to give some alert or anything to warning that if data what i inputed was over that i have.

my code is like this :
Code:
<?php echo form_open(COMPONENTS_CONTROLLER_PATH.'com_creditmanager/deletecredittransactions/', 'id="adminForm" name="adminForm"'); ?>

<table cellspacing="0" cellpadding="2" id="id-componenttable-standardlist" class="componenttable-standardlist">
<tr>
    <td style="text-align: center;">
         &lt;?php echo $this->lang->line('table_credits_on_hand'); ?&gt;
    </td>
    <td colspan="2" style="text-align: center;">
          &lt;?php echo $this->lang->line('table_pay_amount'); ?&gt;
    </td>
</tr>
<tr>
    <td style="text-align: right;" >&lt;?php echo $jobseeker->credits_on_hand; ?&gt;
    </td>
    <td style="text-align: right;">
         &lt;input type="text" name="pay_credit[]" id="pay_credit"  class="form_input" value="&lt;?php echo $jobseeker-&gt;credits_on_hand; ?&gt;" />
         &lt;input type="submit" name="submit" id="submit" value="Pay" class="form_button"&gt;
    </td>
</tr>
</table>

and the view like this :
<a href="http://s521.photobucket.com/albums/w334/tashigiri/?action=view&current=image_03.jpg" target="_blank"><img src="http://i521.photobucket.com/albums/w334/tashigiri/image_03.jpg" border="0" alt="Photobucket"></a>

what i want is just to give alert and forbidden input if inputted more the value i have when button is clicked.
anyone have idea about this???
if have, can you give some example code?


Thanks

regards,


tashi^^
#2

[eluser]umefarooq[/eluser]
hi use form validation in there you can use callbacks to validate the int and limit of value.

http://ellislab.com/codeigniter/user-gui...#callbacks
#3

[eluser]tashigiri[/eluser]
mmhhh... i will try this..
are you know too if using javascript?

thanks so much..
#4

[eluser]David Johansson[/eluser]
you could probably add som javascript to the submit button. Somthing like:
Code:
&lt;input type="submit" name="submit" id="submit" value="Pay" class="form_button" onclick="if(isNaN(document.getElementById('pay_credit').value)||document.getElementById('pay_credit').value&gt;&lt;?php echo $jobseeker->credits_on_hand; ?&gt;) return false;">
You might need to correct some errors...
#5

[eluser]tashigiri[/eluser]
[quote author="David Johansson" date="1248261601"]you could probably add som javascript to the submit button. Somthing like:
Code:
&lt;input type="submit" name="submit" id="submit" value="Pay" class="form_button"&gt;&lt;?php echo $jobseeker->credits_on_hand; ?&gt;) return false;">
You might need to correct some errors...[/quote]

yeah i try to give some javacript "onclick" at button or "onkeydown" at input type.. but i dont know how to give some variabel using javascript that contain php inside that. im still newbie about this..

anyway thanks
#6

[eluser]David Johansson[/eluser]
something went wrong wit my first post, i just edited it...
#7

[eluser]tashigiri[/eluser]
[quote author="David Johansson" date="1248261960"]something went wrong wit my first post, i just edited it...[/quote]
Thanks so much...
ill try this too..^^
#8

[eluser]umefarooq[/eluser]
hi then try jquery inline form validation where u can define only put number and also you can restrict the number or char in feild. and you can also use regular expression in this script to restrict more.

here is link

http://www.position-relative.net/creatio...idator.zip

demo
http://www.position-relative.net/creatio...Validator/
#9

[eluser]David Johansson[/eluser]
wow, that demo's kind of cool Tongue
i love jquery, will soon dig in to it, just need to get more acquainted with codeigniter first
#10

[eluser]tashigiri[/eluser]
[quote author="umefarooq" date="1248262146"]hi then try jquery inline form validation where u can define only put number and also you can restrict the number or char in feild. and you can also use regular expression in this script to restrict more.

here is link

http://www.position-relative.net/creatio...idator.zip

demo
http://www.position-relative.net/creatio...Validator/[/quote]

yes.. the demo so great..
thanks.. but im still dont know a lot about jquery.. :red:




Theme © iAndrew 2016 - Forum software by © MyBB