.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Articles >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Articles

java-script Form Field Name Restrictions

Posted By:Syed Shakeer Hussain       Posted Date: June 22, 2010    Points: 20    Category: Javascript    URL: http://www.dotnetspark.com  

When java-script uses a form field name to validate or otherwise manipulate the field's value, there are certain restrictions on the form field name. Even if the form handling software is more lenient, the field naming must still comply with what java-script expects

For java-script, the form field name must begin with an alphabet character (a through z or A through Z).The rest of the field name may be composed of alphabet characters, digits, and/or underscore characters.

For example, this will work


but this will not, because the form field name contains a space


If a field name can not be changed, the form handler expects it to be named as it is, for example, or if changing the field name creates a lot of work changing other things that rely on the name as it is, than perhaps this will work. Use an id value for the field instead of the field name.

For example, let's suppose this is the field:

The field name, because it contains a space, can not be used in java-script to assign a value to it. However, the field's id can be used.

The id would be used in this way:


ID values begin with a letter and are composed of letters, numbers, and underscore characters. Id values within the source code of a web page must all be unique.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend