Saturday, September 10, 2016

Validation using jQuery Validate


You can easily validate your forms using the library jQuery validate. Just download the latest version of jQuery validate and put it in your server. I'm using codeigniter and the path is /assets/js/jquery.validate.js. Include the file in the head tag of the page after jquery.
<head>
        <script src="<?php echo base_url('assets/js/jquery-2.1.0.min.js');?>"></script>
 <script src="<?php echo base_url('assets/js/jquery.validate.js');?>"></script>
</head>
Suppose you have a form like this, you can easily validate and submit it using ajax.
<form id="myform">
 <input type="text" name="name" placeholder="Enter name"/>
 <input type="text" name="mobile" placeholder="Enter mobile"/>
 <a href="javascript:void(0);" id="enter_data">Enter</a>
</form>
The submitHandler will take care of the ajax part if the form validates to true.
<script>
var site_url = "";
$(document).on('click','#enter_data', function(){
  if($('#myform').valid()) {
    $('#myform').submit();
  }
});
$('#myform').validate({
    rules: {
      // Specify validation rules- left side is the name attribute of form elements
        name: "required",
        mobile: "required"
      },
      // Specify validation error messages
      messages: {
        name: "Please enter name",
        mobile: "Please enter mobile"
      },
    submitHandler: function(form) {
        $.ajax({
            url: site_url+"/admin/enter",
            type: "POST",
            data: $(form).serialize(),
            success: function(res) {
                window.location.reload();
            }            
        });
    }
});
</script>
There are lots of options available for validation. You can read it here https://jqueryvalidation.org/

Saturday, August 6, 2016

Check if files is empty or not using jQuery


You can check if a file field is empty or not using jquery Suppose you have an input field like this
<form id="myForm">
 <input type="file" id="myFile"/>
 <a href="javascript:void(0);" id="check">Check</a>
</form>
You can check if the filed is empty or not like this
<script>
$(document).on('click', '#check', function(){
 if ($('#myFile').get(0).files.length === 0) { 
  console.log("No files selected."); 
 }
})
</script>

Friday, April 22, 2016

Towards the foot of Kannagi, Mangala Devi Temple

Mangala Devi Kannagi temple is a very ancient temple located in Idukki district of Kerala.  The main diety of the temple is Kannagi and it has many folk tales associated with  it, like she burned down the city of Madurai because of denying of justice to her husband and came here. You can read more here.
The temple is located deep inside  Periyar Tiger Reserve and surrounded by spectacular  views and lush greenery.  I was aware of this place for some time and located the place in google maps and instantly fell in love with it and added it to my wishlist. If you look at the maps the whole place is surrounded by thick forests and mountain passes and an enticing trail. It would be heaven if two wheelers can be brought here. But sadly and unfortunately the entry to this place is restricted to only one day in an year, which is the Chitra pournami day of Tamil Nadu which is considered as the festival of Mangal Devi  Kannagi temple. Usually it comes in the month of April and local tribes and people from Kerala and Tamil Nadu visit this place to get blessings on this day.
I was very sad that the forest department doesn't allow to visit the place in any other day! Enquired all possibilities about that and came to know that entry is only allowed in the Chitra Pournami day. So by all efforts I decided to hit it because if I didn't make it now then I have to wait another one year to visit there! It was a working day, heck! But I took leave from the office and decided to go there.
Headed to Kumili from Kollam at 4am. The morning ride to Kumili was extremely thrilling as it has lots of high range corners coupled with spectacular ghat views .


Traffic was less and reached Kumili at 8am, had breakfast and prepared for trekking. Kannagi temple is located 17 km away from Kumili and one need to either trek or hire a passenger jeep to reach the temple. The most exciting and adventurous option is to walk through the forests enjoying the picture perfect nature. The sweetest deal of the temple is this 17 km trail.


Started trekking at 8.30am, the path is not hard at the beggining but it will be harder as we progress. There's drinking water facility provided at every 3 kms and it was very helpful in keep us going. There are many people from Kerala and Tamil Nadu along with us to reach the temple. The main problem while trekking is that when the jeeps passes by at certain points where trekking path and jeep path intersect, we will be surrounded by an enormous amount of dust. On the way we can see the western ghats and villages of Theni and Cumbum. The views are superb with high mountains and heavy clouds with greenery everywhere.

 We can see the temple at a very long distance on the top of a mountain. On the way we can see a distant view of Mullaperiyar dam through the mountains.











The trek became very difficult as the sun became harder on us but the driving force of the surrounding sceneries made the trek fruitful. Trekked the whole distance and reached the temple at around 12.30 pm.
 The temple is in a ruined condition only the main structure is left. Had a walk around the area took photos, prayed and left. I wished I had a house on this place such was the atmosphere there. After enjoying the fine trek and tired-to-the-hell body we hired a jeep from the top for the return and reached Kumili at 3.30pm. Had a soothing sleep in a hotel room, return started from Kumili at 6pm and reached Home by 11pm and had a deep peaceful sleep with the sweet-yet-hard trekking memories. I wish to visit the temple next year also, its a totally different kind of experience to move with other fellow local people. I strongly recommend this place to trekkers and travel guys out there
This was the route:
Total 170 km one side: Kollam>Kottarakkara>Adoor>Ranni>Manimala>Kuttikkanam>Kumili

Thursday, March 31, 2016

A Curious One


A moncohrome tryout.

EOS 60D
1/100 sec, f/5.6, ISO-100, 55mm(18-55mm kit lens)