Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
JAVASCRIPT HELP..!!!
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="koondeGoda" data-source="post: 7263166" data-attributes="member: 61636"><p>To validate numbers , make a call for this function in your if condition. pass the user input (s) . hope this helps</p><p></p><p>[PHP]</p><p><script type="text/javascript"></p><p></p><p>function isInteger(s)</p><p>{ var i;</p><p> for (i = 0; i < s.length; i++)</p><p> { </p><p> // Check that current character is number.</p><p> var c = s.charAt(i);</p><p> if (((c < "0") || (c > "9"))) return false;</p><p> }</p><p> // All characters are numbers.</p><p> return true;</p><p>}</p><p></p><p></script></p><p>[/PHP]</p><p></p><p></p><p>OK! here i extended truth4L's code <img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /> </p><p></p><p>[PHP]</p><p></p><p><html></p><p> <head></p><p> <title></title></p><p> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></p><p> <script language="Javascript" type="text/javascript"></p><p></p><p> function validate(){</p><p> var nic_no = document.getElementById('nic').value;</p><p> </p><p> if(nic_no.length == 10 && nic_no.charAt(9)=='V' && isInteger(nic_no.substring(0,9) )){</p><p> alert("NIC number is Valid");</p><p> }else{</p><p> alert("NIC number is Invalid");</p><p> }</p><p> </p><p> }</p><p> </p><p> function isInteger(s) </p><p> { var i; </p><p> for (i = 0; i < s.length; i++) </p><p> { </p><p> // Check that current character is number. </p><p> var c = s.charAt(i); </p><p> if (((c < "0") || (c > "9"))) return false; </p><p> } </p><p> // All characters are numbers. </p><p> return true; </p><p> }</p><p></p><p> </script></p><p> </head></p><p></p><p> <body></p><p> NIC : <input type="text" id="nic"></p><p> <input value="Check" id="check" type="button" onclick="validate()"></p><p></p><p> </body></p><p></html></p><p></p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="koondeGoda, post: 7263166, member: 61636"] To validate numbers , make a call for this function in your if condition. pass the user input (s) . hope this helps [PHP] <script type="text/javascript"> function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } </script> [/PHP] OK! here i extended truth4L's code :P [PHP] <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script language="Javascript" type="text/javascript"> function validate(){ var nic_no = document.getElementById('nic').value; if(nic_no.length == 10 && nic_no.charAt(9)=='V' && isInteger(nic_no.substring(0,9) )){ alert("NIC number is Valid"); }else{ alert("NIC number is Invalid"); } } function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } </script> </head> <body> NIC : <input type="text" id="nic"> <input value="Check" id="check" type="button" onclick="validate()"> </body> </html> [/PHP] [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom