Solved javascript textbox

Posted on 2011-10-12
Last Modified: 2012-05-12

I am trying to add javascript onClick and onBlur as textbox attributes from the script

Its working OK however W3c validator is not recognise these attributes and returning 1 error on the page

>> there is no attribute "onClick"
>> there is no attribute "onBlur"

Please can someone advise if there is any problem in the following

txtSearch.Attributes.Add("onClick", "this.value='';")
txtSearch.Attributes.Add("onBlur", "javascript:if (this.value=='') this.value='Search for...';")

Question by:daira
    LVL 8

    Accepted Solution



    txtSearch.Attributes.Add("onclick", "this.value='';")
    txtSearch.Attributes.Add("onblur", "javascript:if (this.value=='') this.value='Search for...';")

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now