• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Access Textbox value in Content PlaceHolder thru Javascript

Hi Experts,
I have a aspx page which uses a Master Page.  I have a text field inside the Content Placeholder.  I want to change the data to Uppercase whenever it is entered thru a Javascript.  The question is, how would I access the textfield in Javascript?  Please let me know.  Thank you very much in advance.
0
RadhaKrishnaKiJaya
Asked:
RadhaKrishnaKiJaya
  • 4
  • 4
  • 2
2 Solutions
 
skullnobrainsCommented:
you need to apply a js function to the unchange event of your form control

use the touppercase js method to change the value.something like
document.getElementById('yourElement').value=document.getElementById('yourElement').toUppercase()

you may also apply the same when the formis submitted

you probably should handle this server side if you can
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank you skullnobrains,
I tried your line and got the below error message.  In fact the javascript fails and gives me this error.  When I remove the .value from the line, I get the 'null' value.  But, javascript still runs.  Any idea?  Thank you again for your help.

I am testing this line
-------------------------------------------
var fname = document.getElementById('txtFName').value;

Error Message
---------------------------------
Microsoft JScript runtime error: Object required
0
 
Sar1973Commented:
Then check your HTML, since no object named 'txtFName' may be defined.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
skullnobrainsCommented:
yes. there should be a single element with this specific id (beware it's id not name when using the code i provided)
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank you everybody for trying to help me.  My issue is not resolved yet though.  Since it is opened long, I am closing this case.
0
 
RadhaKrishnaKiJayaAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for RadhaKrishnaKiJaya's comment #a39177553

for the following reason:

Reason already provided.
0
 
skullnobrainsCommented:
the author has a proper answer. as good as can be given without seeing the html part of the code which he did not provide

i do not care about points, but i stongly disagree with such a question closure
0
 
Sar1973Commented:
I agree with skullNB.
0
 
skullnobrainsCommented:
i would recommend a split between Sar1973's comment 39176849 and my first comment  39175537
0
 
RadhaKrishnaKiJayaAuthor Commented:
Hi skullnobrains and Sar1973,  I really appricate your answers.  But I don't know why it did not work for me.  I am not experts on this either.  I am really sorry, but I provided my reply honestly.  Please look below for my explanation.  Hope that helps.

Here is what I did in my page load.

txtDate.Attributes.Add("onblur", "return ValidDate(this)");

This is my aspx program.

<script type="text/javascript">

     function checkdate(input) {

            var Day = input.value.split("/")[0];
            var Month = input.value.split("/")[1];
            var Year = input.value.split("/")[2];

            input.value = Day + "/" + Month.toUpperCase() + "/" + Year;
     }

</script>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now