Welcome to TBD.my, Guest! Log In or Sign Up
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Js function, help me...
08-07-2012, 03:28 PM
Post: #1
Js function, help me...
Hello,

How to build a simple js function that, if a text field's max char is 10. Then, after the char on text field is reach 10, automatically pop out alert. Help me please.

Trust, but verify - Ronald Reagan Challenge Accepted
Quote
08-07-2012, 03:45 PM
Post: #2
RE: Js function, help me...
so just limitkan 10 chars je dlm textbox tu?
Code:
http://stackoverflow.com/questions/3414916/display-only-10-characters-of-a-long-string
ni kot

[Image: 01po9.gif]
Quote
08-07-2012, 03:51 PM
Post: #3
RE: Js function, help me...
(08-07-2012 03:45 PM)p0pc0rn Wrote:  so just limitkan 10 chars je dlm textbox tu?
Code:
http://stackoverflow.com/questions/3414916/display-only-10-characters-of-a-long-string
ni kot

itu substr kn? itu nk amik certain text kn? sy punye lain.. die mcm ni, bile kite masuk huruf pertama, die xjd ape2.. yg kedua smpai ke sembilan pun x jd ape2.. tp, bile masuk char yg ke 10, baru keluar pop up alert.. boleh ke?

Trust, but verify - Ronald Reagan Challenge Accepted
Quote
08-07-2012, 08:47 PM
Post: #4
RE: Js function, help me...
boleh try kaji onkeyup event kat form tersebut

puas sudah menanam ubi, nenas juga dibeli orang, puas sudah aku berbakti, pengganas juga dipandang orang

TBD Challenge
Quote
09-07-2012, 05:39 AM
Post: #5
RE: Js function, help me...
Code:
<!-- script -->
<script type="text/javascript">
function NoMore()
{
var x=document.getElementById("myBox");
var textLength = x.value.length;
if(textLength > 10)
{
    alert("Opss, alredy more den 10. wanna troll me? ;D ");
}
}
</script>

<!--form-->
Must !>= 10: <input type="text" id="myBox" onKeyUp="NoMore()" />

camni ka?

Smile jgn ban saye. ade silap tulun tunjukan Smile
Quote
10-07-2012, 03:41 AM
Post: #6
RE: Js function, help me...
(09-07-2012 05:39 AM)PistolCodez Wrote:  
Code:
<!-- script -->
<script type="text/javascript">
function NoMore()
{
var x=document.getElementById("myBox");
var textLength = x.value.length;
if(textLength > 10)
{
    alert("Opss, alredy more den 10. wanna troll me? ;D ");
}
}
</script>

<!--form-->
Must !>= 10: <input type="text" id="myBox" onKeyUp="NoMore()" />

camni ka?

okeyh... mcm ni la gak rupenye... tqvm! lg 1 kn.. kalau textbox tu x key-in pakai keyboard cmne? contohnya pakai barcode reader... die xgune "onKeyUp" la kan? cmne tu? ade hint? =)

Trust, but verify - Ronald Reagan Challenge Accepted
Quote
10-07-2012, 07:12 AM
Post: #7
RE: Js function, help me...
(10-07-2012 03:41 AM)apitmanu Wrote:  
(09-07-2012 05:39 AM)PistolCodez Wrote:  
Code:
<!-- script -->
<script type="text/javascript">
function NoMore()
{
var x=document.getElementById("myBox");
var textLength = x.value.length;
if(textLength > 10)
{
    alert("Opss, alredy more den 10. wanna troll me? ;D ");
}
}
</script>

<!--form-->
Must !>= 10: <input type="text" id="myBox" onKeyUp="NoMore()" />

camni ka?

okeyh... mcm ni la gak rupenye... tqvm! lg 1 kn.. kalau textbox tu x key-in pakai keyboard cmne? contohnya pakai barcode reader... die xgune "onKeyUp" la kan? cmne tu? ade hint? =)

aku rasa barcode reader tu pun guna onkeyup.. cuma dia tulis laju, dah tak silap aku dia akan enter sendri kan?

atau ko boleh guna onchange selain onkeyup tu.. so bila content textbox tu berubah je dia akan execute NoMore(), tapi kelemahan dia aku rasa dia akan check kalau x fokus pada textbox tu..

contoh --> http://www.w3schools.com/jsref/tryit.asp...f_onchange
lepas ko tulis, dan ko klik mana2 kat luar kotak tu baru dia execute uppercase() tu..

[Image: GteM3.png]
Quote
10-07-2012, 12:54 PM
Post: #8
RE: Js function, help me...
(10-07-2012 07:12 AM)suhz Wrote:  
(10-07-2012 03:41 AM)apitmanu Wrote:  
(09-07-2012 05:39 AM)PistolCodez Wrote:  
Code:
<!-- script -->
<script type="text/javascript">
function NoMore()
{
var x=document.getElementById("myBox");
var textLength = x.value.length;
if(textLength > 10)
{
    alert("Opss, alredy more den 10. wanna troll me? ;D ");
}
}
</script>

<!--form-->
Must !>= 10: <input type="text" id="myBox" onKeyUp="NoMore()" />

camni ka?

okeyh... mcm ni la gak rupenye... tqvm! lg 1 kn.. kalau textbox tu x key-in pakai keyboard cmne? contohnya pakai barcode reader... die xgune "onKeyUp" la kan? cmne tu? ade hint? =)

aku rasa barcode reader tu pun guna onkeyup.. cuma dia tulis laju, dah tak silap aku dia akan enter sendri kan?

atau ko boleh guna onchange selain onkeyup tu.. so bila content textbox tu berubah je dia akan execute NoMore(), tapi kelemahan dia aku rasa dia akan check kalau x fokus pada textbox tu..

contoh --> http://www.w3schools.com/jsref/tryit.asp...f_onchange
lepas ko tulis, dan ko klik mana2 kat luar kotak tu baru dia execute uppercase() tu..

tq 4 sharing... aku xpasti yg barcode reader to boleh ade effect onkeyup ke x.. kene cube dulu la.. tq again! ^^

Trust, but verify - Ronald Reagan Challenge Accepted
Quote


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  jvectormap marker + css + jquery function r3v3r7 8 332 02-02-2013 02:23 AM
Last Post: r3v3r7
  script ape kah ini?ape function dia? RFC792 11 1,680 27-05-2010 06:01 AM
Last Post: RFC792

Forum Jump:


User(s) browsing this thread: 1 Guest(s)