Featured
-
How to split a String
Below I have written a code to split a string.
by shahbaz.ahmmod -
Send Push Notification with Custom Data to iPhone device from Java Server Side
This blog will help you to send Push Notifications
by babita.dhami -
Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified”
If you are adding Server in Eclipse for Tomcat, an
by chandan.ahluwalia -
Spring MVC and MongoDB
Repository Class Using MongoDB : Spring has th
by sumit.vyas -
How to create DLL file from java?
Hello Guy's This Blog will guide how to create D
by bhagwan.khichar
Tags
Pass Element ID that Triggers `onclick` Event to the Event Handling Function
When we apply onclick event to an element, sometimes we need to pass ID of that element to the event handling function. We can do this by passing id to function as this.id or we can pass the element itself.
Example: In the below example I&...
Getting current url in jQuery
Sometimes we need to identify which is the current URL of JSP page to perform some functionality. We can do this very easily by adding the below line in you on load function:
$(function(){
var url = window.location.href;
...
How to make AJAX call in jQuery?
Sometimes we need to make AJAX call in our Web page. The purpose of AJAX call is that you want to get/submit data without refreshing your page or you want to submit your form by calling an API. We can do this very easily by using ajax() method of...
How to push values in array in jQuery?
Sometimes we need to insert valuse in an array, we can do this by using push() method of jQuery very easily.
Example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-...
How to validate a form on submit?
Whenever we create a form, we always have a requirement to put validation for empty fields on some input fields on form submit. For this we use onSubmit attribute of the form, inside which we can define a function that will have validations.
E...
How to check if an array contains a specific string in jQuery?
Sometimes we need to check if a particular string exists in an array or not, we can do this by using inArray() method of jQuery very easily.
Example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"&g...
How to open another page with button click in jQuery?
Sometimes we need to open another page on button click.
We can do this in tow ways either by using "window.location" or "window.open()".
Example: In the below example I have put conditions on "blur" event for checking whether the input fiel...
How to implement autocomplete feature with AJAX in jsp?
Sometimes wee need to call an API or action to get matching list with the provide keyword in Search box, for this we usually implemente autocomplete feature to input field for searching purpose by doing AJAX call.
Example: In the below example...
How to check/uncheck checkbox with jQuery?
Sometimes we need to check/unchecked checkbox based on some condition. We can do this easily by using "checked" attribute of a button.
Example:
<input type="checkbox" id="addressCheckBox" class="form-control">
<label>I confir...
How to apply autocomplete feature to textbox with jQuery?
Sometimes we need to implement autocomplete feature to input field for searching purpose. We can do this by using "autocomplete()" with jQuery.
Example: In the below example I have created an array of country names and passed that as source to...
How to implement validation for empty input field with jQuery?
Whenever we create a form, we always have a requirement to put validation for empty fields on some input fields. We usually implement this functionality by putting checks on "blur" and onFocus events of the input field.
Example: In the below e...
How to apply validation on checkbox with jQuery?
Sometimes we need to check whether a checkbox is checked or not. We can do this easily by using "checked" attribute of a checkbox.
Example: In the below I have created a function validateCheckBox() that checks whether a checkbox is checked or ...
How to implemente confirm password functionality with jQuery?
At the time of registration or change password we need to provide password, so for this we usually implement Confirm password functionality.
Example: In the below example I want to confirm password on form submit, so for this I have created a ...
How to select option of drop down with Jquery?
Sometimes we need select option of a drop-down dynamically by clicking on a button or on some other action. We can do this by using "selected" property.
Example- In the below example I have a drop-down for distance and I want to select option ...
How to appned li elements to ul dynamically with jQuery?
Sometimes we need to add li elements to ul dynamically based on some list. We can do this by using append() method.
Example- In the below example I have a list "users" and I want to display user names dynamically on page.
<html>
...
How to show div after some time period with jQuery?
Sometimes we need to display some alert or dive after some period on Web page.
We can do this by using setTimeout method as below:
<html>
<head>
<title>Demo to show div</title>
<script type="...
How to hide a message after some time interval with jQuery?
Whenever we submit a form or do some task, we usually display a success message, but sometimes it is required to hide this message automatically after some time period.
We can do this by two ways:
By using setTimeout method:
...
How to add/remove class to an element on keyup event with jQuery?
We can add or remove a class to an element very easily by using addClass() and removeClass() methods. To do this on keyup event of a textbox we just need call these functions when we bind keyup event to textbox.
Example:
<input id="sear...
How to enable/disable a button with jQuery?
Sometimes we need to enable/disable a button based on some condition. We can do this easily by using "disable" attribute of a button.
Example:
<button type="button" id="voteButton">vote</button>
To disable a button write t...
How to refresh a function after a particular time in jsp?
To refresh a function after a particular time interval to refresh the values on the page.
We can do this by using setInterval() function on page load.
Write the below code where refresh() function will be the function that you want to refresh...
How to focus a text box on button click in jQuery?
Sometimes we need to focus a textbox on button click based on some condition. We can do this by using focus().
Example- Suppose I want to focus search-box on button click if the search-box is empty, then we can do this as below:
<input i...
how to identify location is enable or not on browser with jQuery?
To get the user's current location use the getCurrentPosition() method. This method contains two parameters, first parameter is success for providing locationd and second one is error to handle errors for ex: getCurrentPosition(success,error)
...
How to get browser current timezone with jQuery?
Sometimes we need to identify the clients timezone to make some calculation on time. For example - we want to save current time based on user's timezone into database, so in this case we need to get the user's current timezone.
To do this down...
How to detect if enter key is pressed with jQuery or not?
Sometimes we need to detect where ENTER key is pressed or not to do some action.
The "enter" key is represent by code 13 (ASCII value).
To detect whether ENTER key is pressed on Web-page or inside an input field, we can bind keypress() eve...
How to find the size of a file while uploading in JSP?
Sometimes we need to find the size of a file at the time of uploading to prevent the file that is greater than a particular size. We can achieve this by handling "change" event of a input-file.
Examlpe: Suppose I want to upload a file less tha...
How to find the extension of a file to be uploaded in JSP?
Sometimes we need to find the extension (file-type) of a file at the time of uploading to apply some validation on it. We can do this by handling "change" event of input-file.
Example: In the below example I want to upload the file having exte...
Fading in and out an element using jQuery
Sometimes we want an image, control or element in a page to fade in and out of visibility .With jQuery it can be done easily. Below are examples of fade in and out method for a div element:
Fade In: fadeIn() method is used to fade in a hidd...
How to clear all textboxes in a form using jQuery
Hi readers !
In this blog we will see how we can clear all textboxes in a form using jQuery .
To clear a textbox with id 'txtBox1' in javascript we use below code :
document.getElementById('txtBox1').value = '';
We can use this cod...
How to set and get href attribute in jQuery?
Sometimes we need to set and get value of href attribute of <a> tag from jQuery. We can do this very easily by using element.attr() function in jQuery.
Example: for example you declare an <a> as below:
<a id="element_url" hr...
Image Crop Using Java and Jquery Crop (Jcrop)
FrontEnd:
Include jquery.Jcrop.css, jquery.Jcrop.js and jquery.Jcrop.min.js
Open an image in a div with a form. Take 4 hidden input fields:
<input type="hidden" id="x" name="x" /> // x coordinate of the image
<input type="hidde...
Sample application using JQuery, Spring MVC @RequestBody and JSON together
See the below steps to create sample application using JQuery, Spring MVC @RequestBody and JSON :
1- Define dependency for Spring, JSON in pom.xml as below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/...