Click here to Skip to main content

JavaScript

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionMessage Automatically Removedmembertidelgl19:18 13 Jan '13  
Message Automatically Removed
QuestionRegular ExpressionmemberAB77714:10 11 Jan '13  
Hi all,
I have scenario where a string can contain '$' only at the start, I was able to create a regular expression for this validation, but now another scenario is the same string can be repeated by a ',' delimiter. Now what happens is since I don't allow the '$' in the string except for the first position, when I repeat the same string after ',' starting with '$' the validation fails.
 
Is there anyway in which we can restrict a character uptil some delimiter and then again allow it?
 
Any pointers would be appreciated.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"

QuestionHow to put clipboard data into TextBoxmemberRavindra Bisen0:02 10 Jan '13  
Hi ,
I have a string into clipboard (FirstName MiddleName Last Name). i want to paste this data into three different Textbox by a single paste in First Textbox.
 
ex . if i paste "Ravi Shankar Sharma"
then the data should appear like this
First Text box : Ravi
Second Text Box: Shankar
Third text box : Sharma
 
any one can help me
AnswerRe: How to put clipboard data into TextBoxmemberJ4amieC2:39 10 Jan '13  
jQuery solution is pretty simples, but there is one weirdness, you cant read the value of the field until after it's been pasted, so I intoduce a short 1ms delay between paste, and trying to update the field:
 
$('#first').on('paste',function(e){
  
  setTimeout(function(){
    var text = $('#first').val().split(' ');
    $('#first').val(text[0]);
    $('#second').val(text[1]);
    $('#third').val(text[2]);  
  },1)
});
 
Live example: http://jsfiddle.net/PjT28/[^]
 

I also don;t cover any of the multitude of error conditions (empty paste, paste without 3 names separated by a single space etc etc etc)
AnswerRe: How to put clipboard data into TextBoxmemberRavindra Bisen23hrs 56mins ago 
<html>
<head>
<title>Java Script - Capita Learning : ClipBoard Data </title>
 
<script type="text/javascript" >
 
    function afterPaste(txt)
    {
      var T = window.clipboardData.getData('Text');
      document.getElementById('Txt_Data2').value = T;
      document.getElementById("Txt_Data3").value = T;
       var len = T.length;
       var n = T.indexOf(" ");
        document.getElementById("Txt_Data2").value = T.substring(0,n);
        T = T.substring(n+1,len);
        len = T.length;
    n = T.indexOf(" ");
        document.getElementById("Txt_Data3").value = T.substring(0,n);
    document.getElementById("Txt_Data4").value = T.substring(n+1,len);
 
    }
 

 
 </script>
</Head>
<body>
<p> On Paste event in java script
<p> <Input Type="Textbox" ID="Txt_Data" OnPaste="afterPaste(this.value)" >
<p> <Input Type="Textbox" ID="Txt_Data2" Name="Txt_Data2" >
<p> <Input Type="Textbox" ID="Txt_Data3" Name="Txt_Data3" >
<p> <Input Type="Textbox" ID="Txt_Data4" Name="Txt_Data4" >
 
</body>
</html>

QuestionjQuery: live() functionmemberPhanindra2610:27 9 Jan '13  
The live() in the jQuery has been deprecated. Does anyone know the reason why?
AnswerRe: jQuery: live() functionmemberJ4amieC0:39 9 Jan '13  
They hide that sort of information in the documentation[^], the little buggers!
 
Use of the .live() method is no longer recommended since later versions of jQuery offer better methods that do not have its drawbacks. In particular, the following issues arise with the use of .live():
 
    jQuery attempts to retrieve the elements specified by the selector before calling the .live() method, which may be time-consuming on large documents.
    Chaining methods is not supported. For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
    Since all .live() events are attached at the document element, events take the longest and slowest possible path before they are handled.
    On mobile iOS (iPhone, iPad and iPod Touch) the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
        Use natively clickable elements such as a or button, as both of these do bubble to document.
        Use .on() or .delegate() attached to an element below the level of document.body, since mobile iOS does bubble within the body.
        Apply the CSS style cursor:pointer to the element that needs to bubble clicks (or a parent including document.documentElement). Note however, this will disable copy\paste on the element and cause it to be highlighted when touched.
    Calling event.stopPropagation() in the event handler is ineffective in stopping event handlers attached lower in the document; the event has already propagated to document.
    The .live() method interacts with other event methods in ways that can be surprising, e.g., $(document).unbind("click") removes all click handlers attached by any call to .live()!
 

QuestionGoogle+ login on my websitemembermarcbase11:16 8 Jan '13  
So I am looking for a simple way for users to login to my website using their google+ account
 
I want to use javascript for it, is it possible and could anyone give me a little bit of a plan for it.
 
Let me know!
 
i have been looking around and i only figured it out in Csharp and the main developper wants it in javascript
 
help me out Smile | :)
AnswerRe: Google+ login on my websitemvpSandeep Mewara17:45 8 Jan '13  
It looks, following should help you out: http://code.google.com/p/google-api-javascript-client/wiki/Authentication[^]
 
Try out!
Sandeep Mewara
Microsoft ASP.NET MVP 2012 & 2013
 

[My Latest Article(s)]:
How to extend a WPF Textbox to Custom Picker
Server side Delimiters in ASP.NET

QuestionQuestionmembernth926:25 6 Jan '13  
i have a questions you can help me ??
 
Q1) If you have two definitions for embedded CSS classes; classA , and classB. Write a
    JavaScript statement that will be responsible for changing the DIV tag CSS class shown
    below to classB ?
<div name=”section1” class=”classA”> …… </div>
 
A.  section1.style.className="classB"
B.  section1.class="classB"
C.  div.className="classB"
D.  section1.className="classB"
 

Q7. Which of the following is the correct JavaScript syntax to assign the file "bird.jpg" to the src property of an Image object called newImage?
A. newImage = "bird.jpg";
B. newImage.open("bird.jpg");
C. newImage.src("bird.jpg");
D. newImage.src = "bird.jpg";
 

Q8.The following code will:
var str="welcome in web";
document.writeln(str.link("www.web.com"));
 
A. display on the browser www.web.com as a hyperlink.
B. display on the browser welcome in web as a hyper link.
C. not display anything on the browser.
D. it is an error to write this javascript code.
 

Q11. For a webpage containing only one form shown below how can we obtain the value
      entered inside the textbox in JavaScript?
 
<form name="sub">
      First Number:  <input type = "text" name = "first" size = "5"/> </form>
 
A.  document.forms[1].first.value
B.  sub.first.value
C.  window.forms[0].first.value
D.  sub.text.first.value
 

Q12. If we have the following radio buttons in form named Form1, which line of code
      below could be used to determine if the Female option is checked?
 
Male <input type = "radio" name="gender" value="M" checked/>
Female <input type = "radio" name="gender" value="F"/>
 
A.  Not checked since the Male option is already checked and cannot be changed.
B.  Form1.gender[1].click();
C.  Form1.gender.checked;
D.  Form1.gender[1].checked;
 
Q13. Suppose that a JavaScript function was called upon pressing a form’s Submit
      button. Which one of the following JavaScript code lines could prevent the action
      of sending the form’s data to the server?
 
A.  window.event.returnValue = false;
B.  window.event.returnValue = true;
C.  confirm( "Are you sure you want to reset?" );
D.  window.event.formValue = false;
 

Q19) The output of the following html document is:
<html><head><title></title><script type = "text/javascript"> <!--
var count = 1;   while (count <= 5)
{ if(count % 3 == 0) document.write("***");
  else document.write("++++");
   document.write( "<br/>" );
 count++;}  // -- >
</script></head><body></body></html>
 
A) ++++              B) ++++++++***++++              C) ****                        D) +++++
 ++++
       ***
 ++++
 ++++

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.13014.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid