Skip to content

Instantly share code, notes, and snippets.

@bandicsongor
bandicsongor / is_numeric.js
Created November 8, 2013 15:53
isNumeric
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
@bandicsongor
bandicsongor / javascript_ucfirst.js
Created November 6, 2013 10:39
PHP's ucfirst function
function capitaliseFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
@bandicsongor
bandicsongor / validate_cui.php
Last active June 6, 2017 12:05
Validare cui, cui validation, CUI validalas, validare CIF, CIF validation, CIF validalas
function validare_cui( $cif )
{
if (!is_numeric($cui))
return false;
// Exista CUI -uri mai scurte de 6 cifre pe care sunt valide. (Ex. 5229, 52298)
if (strlen($cui) < 4 || strlen($cui) > 10)
return false;
$cifra_control = substr($cui, -1);
$cui = substr($cui, 0, -1);
@bandicsongor
bandicsongor / validate_cnp.php
Last active March 2, 2017 07:06
Validare cnp, cnp validation, CNP validalas
function validare_cnp( $cnp )
{
$constanta = "279146358279";
if ( strlen($cnp) != 13 )
{
return FALSE;
}
$suma = 0;
@bandicsongor
bandicsongor / isLetter
Created August 8, 2013 12:56
can be used on textboxes to verify it the pressed key is a letter or not, usage: onkeypress = 'return isLetter(event)'
function isLetter(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122))
{
return false;
}
return true;
}
@bandicsongor
bandicsongor / isNumber
Created August 8, 2013 12:54
cand be used on textboxes to verify if the pressed key is a number, can be used as: onkeypress = 'return isNumber(event)'
function isNumber(evt)
{
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
@bandicsongor
bandicsongor / ucfirst_javascript
Created July 9, 2013 13:48
Uppercase first caracter from a string
function capitaliseFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
@bandicsongor
bandicsongor / validate_cnp
Created June 14, 2013 14:27
Validare cnp, cnp validation, CNP validalas
function valideazacnp(cnp) {
var constanta= "279146358279";
if(cnp.length!=13) return false;
var suma=0;
for(i=0; i<constanta.length; i++) {
suma=suma+cnp.charAt(i)*constanta.charAt(i);