Ajax call using jquery

function makeAjaxRequest(data1,data2,.....,datax){
        async: false,
        url: 'http://www.example.com/some_request_url',
        success : function(response) {
            console.log(response); // Using this you can check the posted data in browser console window
            return true;// you can process and return the response as required
            //location.reload(); // or you may reload the current page also
        error: function (jqXHR, exception) {
            // If some error is returned, you can check the details below
            var msg = '';
            if (jqXHR.status === 0) {
                msg = 'Not connect.\n Verify Network.';
            } else if (jqXHR.status == 404) {
                msg = 'Requested page not found. [404]';
            } else if (jqXHR.status == 500) {
                msg = 'Internal Server Error [500].';
            } else if (exception === 'parsererror') {
                msg = 'Requested JSON parse failed.';
            } else if (exception === 'timeout') {
                msg = 'Time out error.';
            } else if (exception === 'abort') {
                msg = 'Ajax request aborted.';
            } else {
                msg = 'Uncaught Error.\n' + jqXHR.responseText;
            $('#post').html(msg); // return the error response in your html page or process it further as required


Validate date format mm/dd/yyyy by using jquery validation library

First add the custom method to the validation library as below. Can you put this code in your jquery validation file or in your page where you want to validate the date, just before setting your validation rule for your form.

 function (value, element) {
 return value.match(/^(?:(0[1-9]|1[012])[\/.](0[1-9]|[12][0-9]|3[01])[\/.](19|20)[0-9]{2})$/);
 },“Please enter a date in the format mm/dd/yyyy.”);

Now suppose you are using a datepicker or input field to accept the date in mm/dd/yyyy format like 02/21/2018 as example. You can validate it as below;


<form id="your-form-id">
<input id="submission_date" name="submission_date" type="text" />
<input type="submit" value="submitForm" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js">
 <script type="text/javascript">

 rules: {
 submission_date: {
 required: true,
 dateFormat: true,
 messages: {
 submission_date: {
 required: "Please select or enter the submission date!!.",
 dateFormat: "Submission date should in the format mm/dd/yyyy.",
 errorPlacement: function(error, element) {
 submitHandler: function (formName) {

Validate date format mm/dd/yyyy in jquery or javascript

<script type="text/javascript">

function isValideDate(datavalue){
 var regexValidDate = /^(?:(0[1-9]|1[012])[\/.](0[1-9]|[12][0-9]|3[01])[\/.](19|20)[0-9]{2})$/;
 return regexValidDate.test(datavalue);

var dateToCheck = '06/01/2011',


alert("Given date is valid as per the format of MM/dd/YYYY");


alert("Given date is not valid as per the format of MM/dd/YYYY");




validate zipcode pincode on keypress using jquery

How to validate and restrict unwanted character for zipcode or pincode field using jquery

$(document).ready(function () {
$(‘#pincode’).keyup(function () {
var $th = $(this);
$th.val($th.val().replace(/[^0-9]/g, function (str) {
return ”;