Tag Archive for check

PHP ファイルが存在するかチェックする

<?php
// ファイルがあるかチェック
$PATH = $_GET['path'];
if(file_exists($PATH)){
$file_exists = true;
}else{
$file_exists = false;
}
echo 'file_exists='.$file_exists;

source

add Slashes Check Magic quotes function

public function addSlashesCheckMagic($data)
{
if (!get_magic_quotes_gpc())
{
$data = addslashes($data);
}

return $data;
}

source

Find Verbose IDs in the DOM

var allTags = document.body.getElementsByTagName('*');
var ids = [];
var longId = 0;
for (var tg = 0; tg< allTags.length; tg++) {
var tag = allTags[tg];
if (tag.id) {
ids.push(tag.id);
if (tag.id.length > 30) longId++;
}
}
alert(longId + " out of " + ids.length + " IDs are too long.")

source

script.aculo.us check state by 24ways

Effect.OpenUp = function(element) {
element = $(element);
new Effect.BlindDown(element, arguments[1] || {});
}

Effect.CloseDown = function(element) {
element = $(element);
new Effect.BlindUp(element, arguments[1] || {});
}

Effect.Combo = function(element) {
element = $(element);
if(element.style.display == ‘none’) {
new Effect.OpenUp(element, arguments[1] || {});
}else {
new Effect.CloseDown(element, arguments[1] || {});
}
}

source

validación de formularios

<script language="JavaScript" type="text/javascript">
//<!--
function checkform(form){
if(form.campo1.value == ""){
alert("Mensaje de alerta 1");
form.campo1.focus();
return false;
}
if(form.campo2.value == ""){
alert("Mensaje de alerta 2");
form.campo2.focus();
return false;
}
return true;
}
//-->
</script>

source

Check if a value is numeric or not

function checkNumeric(value){
var anum=/(^d+$)|(^d+.d+$)/
if (anum.test(value))
return true;
return false;
}

source

Check or Uncheck all checkboxes on a form

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}

source

Php – Validar Fechas

function validarFecha( $fecha, $invertir = 1 ){
if( $invertir == 1 ) $fecha = implode( "-", array_reverse( preg_split( "/D/", $fecha ) ) );
$fecha = explode("-",$fecha);
if( sizeof( $fecha ) != 3 ) return false;
if( checkdate( $fecha[1],$fecha[0],$fecha[2]  ) ) return true;
else return false;
}

source

Does an object have a specific property?

if ("foo" in myObject) {}

source

Check if integer _value_

/**
* Check if a number is a counting number by checking if it
* is an integer primitive type, or if the string represents
* an integer as a string
*/
function is_int_val($data) {
if (is_int($data) === true) return true;
elseif (is_string($data) === true && is_numeric($data) === true) {
return (strpos($data, '.') === false);
}
return false;
}

source