JavaScript Tutorials
- What is Javascript?
- What is BOM?
- What is DOM?
- Variable
- check variable value is empty
- JavaScript Output
- Functions
- Javascript Events
- Input Events
- onchange Event
- Javascript Output methods
- If else statement
- Arrays
- Pattern Validation
- Form Validation
- Inner Html Form Validation
- Inline Form Validation
- Checkbox Validation
- Inline Inner Html Form Validation
- Server side php Validation
- Validate a HTML Form with PHP
- window and window location
- Get Text Value
- Get hidden field value
- JavaScript & PHP
- Date Format
- get php value in javascript
- Redirect page & Autoredirect page
- Auto Refresh page & Div
- How to get select text value from Dropdown box
- How to clear browser history in javascript
- Checkbox Problems
- Select option problems
- Popup Contact Form
- Sidebar Contact Form
- How to use a multistep Form or Form wizard
- Auto Calculate Price
- print Application Form
- Auto Calculate GST in Javascript by select price
- Calculate GST by input value in text box Jquery
- Calculate Discount
- onClick Checkbox
- autofil form data click on checkbox
- Show subcategory list
- Show city list as per state
- Show district list as per country and state
- Show good morning good night wish
- image upload with preview image
- Print Div Content
- Show modal popup on page load
- filter table data usign javascript.
- Character Limit Validation.
- Validate File 5MB Upload
- Validate Special character
- More File Upload
- Call JavaScript Function After Page Load
- Drop Down First option Value Disabled --- Please Select ---
- How to Disable Submit Button After Form Submission
- How to disable browser back button using Jquery?
- How to Remove selected item from second & third dropdown list?
- Interview Questions of JavaScript.
Important Link
How to convert date in different format in javascript.
How to convert date in different format in javascript.
File name : index.php
function dateFormat(inputDate, format) {
//parse the input date
const date = new Date(inputDate);
//extract the parts of the date
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
//replace the month
format = format.replace("MM", month.toString().padStart(2,"0"));
//replace the year
if (format.indexOf("yyyy") > -1) {
format = format.replace("yyyy", year.toString());
} else if (format.indexOf("yy") > -1) {
format = format.replace("yy", year.toString().substr(2,2));
}
//replace the day
format = format.replace("dd", day.toString().padStart(2,"0"));
return format;
}
console.log('Converted date: '+ dateFormat('12/10/2022', 'dd-MM-yyyy'));
How to set min date & Max date in datepicker
File name : index.php
<script type="text/javascript">
$( document ).ready(function() {
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
today1 = dd + '-' + mm + '-' + yyyy;
var fmdate= today
var month = parseInt(fmdate.substr(5,2));
var day = fmdate.substr(8,2)
var year = fmdate.substr(0,4)
var new_year = year-1;
if(month < 10)
month = '0' + month.toString();
var x=2
totalmonth=parseInt(month)+parseInt(x)
var datefrom = new_year + '-' + month + '-' + day;
//$('#date_35').attr('min', maxDate);
$('#date_from').attr('min',"2018-01-01");
$('#date_from').attr('max',today);
$('#date_to').attr('min',"2018-01-01");
$('#date_to').attr('max',today);
$('#date_from').val(datefrom);
$('#date_to').val(today);
});
</script>
File name : index.php