HTML DOM इनपुट माह defaultValue प्रॉपर्टी एक HTML दस्तावेज़ में टाइप ="माह" के इनपुट फ़ील्ड के डिफ़ॉल्ट मान को लौटाती है और संशोधित करती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
1. डिफ़ॉल्ट मान लौटाना
object.defaultValue
2. डिफ़ॉल्ट मान को संशोधित करना
object.defaultValue=value
यहां, मान स्ट्रिंग के रूप में कोई भी तारीख है, उदाहरण के लिए "2019-03"
उदाहरण
आइए हम HTML DOM इनपुट माह का एक उदाहरण देखें defaultValue संपत्ति -
<!DOCTYPE html>
<html>
<head>
<style>
html{
height:100%;
}
body{
text-align:center;
color:#fff;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)
center/cover no-repeat;
height:100%;
}
p{
font-weight:700;
font-size:1.2rem;
}
input{
width:35%;
border:2px solid #fff;
background-color:transparent;
color:#fff;
font-weight:bold;
padding:8px;
}
.btn{
background:#0197F6;
border:none;
height:2rem;
border-radius:2px;
width:35%;
margin:2rem auto;
display:block;
color:#fff;
outline:none;
cursor:pointer;
}
.show{
font-size:1.5rem;
font-weight:bold;
}
</style>
</head>
<body>
<h1>DOM Input month defaultValue Example</h1>
<p>Hi, Enter your month of birth</p>
<input type="month" class="monthInput">
<button onclick="changeValue()" class="btn">Submit</button>
<div class="show"></div>
<script>
function changeValue() {
var monthInput = document.querySelector(".monthInput");
var showMsg = document.querySelector(".show");
monthInput.defaultValue = "1997-10";
monthInput.value= monthInput.defaultValue;
showMsg.innerHTML =":D hehe I changed your month of birth into mine!";
}
</script>
</body>
</html> आउटपुट
यह निम्नलिखित परिणाम देगा -

अब अपना जन्म का महीना दर्ज करें और फिर “सबमिट करें . पर क्लिक करें "बटन।


यहां आप देख सकते हैं कि आपका चुना हुआ महीना मेरे डिफ़ॉल्ट महीने "अक्टूबर- 1997" से बदल गया है।