
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 Text Name Property
The HTML DOM Input Text name property is used for setting or returning the name attribute of an input text field. The name attribute helps in identifying the form data after it has been submitter to the server.
Syntax
Following is the syntax for −
Setting the name property −
textObject.name = name
Here, name is for specifying the text field name.
Example
Let us look at an example for the text name property −
<!DOCTYPE html> <html> <body> <h1>Input Text name Property</h1> USERNAME: <input type="text" id="USR" name="user_name"> <p>Change the name of the text field by clicking the below button</p> <button onclick="changeName()">CHANGE NAME</button> <p id="Sample"></p> <script> function changeName() { document.getElementById("USR").name ="NEW_USER" ; document.getElementById("Sample").innerHTML = "Text field name is now NEW_USER"; } </script> </body> </html>
Output
This will produce the following output. Only 5 characters are allowed since we have set maxLength 5 −
On clicking the CHANGE NAME button −
Advertisements