Solved

Access Textbox value in Content PlaceHolder thru Javascript

Posted on 2013-05-17
12
497 Views
Last Modified: 2013-05-27
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
Comment
Question by:RadhaKrishnaKiJaya
  • 4
  • 4
  • 2
12 Comments
 
LVL 26

Accepted Solution

by:
skullnobrains earned 250 total points
ID: 39175537
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
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 39176129
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
 
LVL 9

Assisted Solution

by:Sar1973
Sar1973 earned 250 total points
ID: 39176849
Then check your HTML, since no object named 'txtFName' may be defined.
0
 
LVL 26

Expert Comment

by:skullnobrains
ID: 39177274
yes. there should be a single element with this specific id (beware it's id not name when using the code i provided)
0
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 39177553
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:RadhaKrishnaKiJaya
ID: 39179346
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
 
LVL 26

Expert Comment

by:skullnobrains
ID: 39179347
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
 
LVL 9

Expert Comment

by:Sar1973
ID: 39179436
I agree with skullNB.
0
 
LVL 26

Expert Comment

by:skullnobrains
ID: 39180353
i would recommend a split between Sar1973's comment 39176849 and my first comment  39175537
0
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 39192388
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

18 Experts available now in Live!

Get 1:1 Help Now