Sunday, 25 October 2015

Get visitor’s location details from IP address using php

<?php

/*Get user ip address*/
$ip_address=$_SERVER['REMOTE_ADDR'];

/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));

/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];

/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];

/*Comment out these line to see all the posible details*/
/*echo '<pre>';
print_r($addrDetailsArr);
die();*/

if(!$city){
   $city='Not Define';
}if(!$country){
   $country='Not Define';
}
echo '<strong>IP Address</strong>:- '.$ip_address.'<br/>';
echo '<strong>City</strong>:- '.$city.'<br/>';
echo '<strong>Country</strong>:- '.$country.'<br/>';

?>

Friday, 23 October 2015

while loop checkbox validation using javascript

<script>
function validate(){
if($('input[name="check_list[]"]:checked').length == 0) {
    alert('No checkbox is checked');
    return false;
}
  return true;
}
</script>


<form action="" method="post"  onsubmit="return validate();"  enctype="multipart/form-data">

  <input type="checkbox" name="check_list[]" value="">
 <input type="checkbox" name="check_list[]" value="">
  <input type="checkbox" name="check_list[]" value=""> 
 <input type="checkbox" name="check_list[]" value=""> 

<button  class="btn  btn-danger" type="submit" name="upload"> Send </button>
</form>


Friday, 18 September 2015

Datepicker from date to date validation using jquery

<label for="from">From</label>
<input type="text" id="from" name="from" />
<label for="to">to</label>
<input type="text" id="to" name="to" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script>
$(function () {
$("#from").datepicker({
maxDate:+0,
changeMonth: true,
dateFormat: 'dd/mm/y',
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);

}
});
$("#to").datepicker({
maxDate:+0,
changeMonth: true,
dateFormat: 'dd/mm/y',
numberOfMonths: 1,
onClose: function (selectedDate) {
}
});
});</script>

Demo

Wednesday, 16 September 2015

php while loop form validation using jquery

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script><script>
function sendContact(id) {
if(!$("#userName_"+id).val()) {
$("#userName_"+id).focus();
alert('Enter the First Name');
valid = false;
}
return valid;
}
</script>
</head>
<body>

<?php 
$i=1;
while($i<5){
?>
<div>
<label>Name</label>
<input type="text" name="userName" id="userName_<?php echo $i; ?>" >
<input type="submit" name="submit" value="submit" onClick="sendContact(<?php echo $i; ?>);">
<?php $i++; }  ?>


Thursday, 16 April 2015

change drop down event automatically clear in text box

 <select onchange="cleartextbox()">
    <option value="libero">libero</option>
    <option value="Ram">Ram</option>
    </select>
   
    <script type="text/javascript">
    function cleartextbox() {
    document.getElementById("mark").value = "";
    }
    </script>
   
    <label>
    <span>Mark</span>
    <input  type="text" name="mark" id="mark" >
    </label>


Demo

Disable/enable an input using javascript

<script language="javascript">
function codename() {
   

if(document.editpro.checkboxname.checked)
{
document.editpro.name.disabled=false;
document.editpro.city.disabled=false;
document.editpro.mob.disabled=false;
document.editpro.regster.disabled=false;
}
else
{
document.editpro.name.disabled=true;
document.editpro.city.disabled=true;
document.editpro.mob.disabled=true;
document.editpro.regster.disabled=true;
}
}</script>

<form method="post" action="" name="editpro">

<input class="form-control" type="text"  readonly value="" name="email" placeholder="Email">

<input class="form-control" type="text" value="" name="name" disabled="disabled"   placeholder="User Name">

<input disabled="disabled"  class="form-control"id="placepicker" name="city" value=""  type="text" placeholder="City">

<input disabled="disabled"  class="form-control" type="text" name="mob" value="" placeholder="Mobile Number">

 <button type="submit" class="btn  btn-danger" name="regster" disabled="disabled">Submit</button>
 If you Edit Your Info  <input type="checkbox" onclick="codename()" name="checkboxname" value="ON">

</form>


Demo







If you Edit Your Info