Skip to content

Instantly share code, notes, and snippets.

@bandicsongor
bandicsongor / validate_cnp
Created Jun 14, 2013
Validare cnp, cnp validation, CNP validalas
View validate_cnp
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);
@bandicsongor
bandicsongor / ucfirst_javascript
Created Jul 9, 2013
Uppercase first caracter from a string
View ucfirst_javascript
function capitaliseFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
@bandicsongor
bandicsongor / isNumber
Created Aug 8, 2013
cand be used on textboxes to verify if the pressed key is a number, can be used as: onkeypress = 'return isNumber(event)'
View isNumber
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 / isLetter
Created Aug 8, 2013
can be used on textboxes to verify it the pressed key is a letter or not, usage: onkeypress = 'return isLetter(event)'
View isLetter
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;
}
View javascript_ucfirst.js
function capitaliseFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
View is_numeric.js
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
@bandicsongor
bandicsongor / validate_cnp.php
Last active Mar 2, 2017
Validare cnp, cnp validation, CNP validalas
View validate_cnp.php
function validare_cnp( $cnp )
{
$constanta = "279146358279";
if ( strlen($cnp) != 13 )
{
return FALSE;
}
$suma = 0;
@bandicsongor
bandicsongor / validate_cui.php
Last active Jun 6, 2017
Validare cui, cui validation, CUI validalas, validare CIF, CIF validation, CIF validalas
View validate_cui.php
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);