
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input URL Maxlength Property
The HTML DOM Input URL maxLength property returns/sets the maxLength property for input URL. If not defined this property returns ‘-1’.
Syntax
Following is the syntax −
- Returning maxLength attribute
inputURLObject.maxLength
- Set maxLength property to a number
inputURLObject.maxLength = number
Example
Let us see an example of Input URL maxLength property −
<!DOCTYPE html> <html> <head> <title>Input URL maxLength</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form id="Google"> <fieldset> <legend>URL-maxLength</legend> <label for="URLSelect">URL : <input type="url" id="URLSelect" maxLength="10"> </label> <input type="button" onclick="logIN()" value="Log In"> <input type="button" onclick="changeMaxLength()" value="Change Maxlength"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputURL = document.getElementById("URLSelect"); divDisplay.textContent = 'Maxlength: '+inputURL.maxLength; function changeMaxLength() { inputURL.maxLength += 10; divDisplay.textContent = 'Maxlength: '+inputURL.maxLength; } function logIN(){ if(inputURL.value !== '') divDisplay.textContent = 'Could not identify url, Redirecting to '+inputURL.form.id; } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘Change Maxlength’ button −
After clicking ‘Change Maxlength’ button −
After clicking ‘Log In’ button and setting email input −
Advertisements