GeekInterview.com
Series: Subject: Topic:

Java Script Interview Questions

Showing Questions 1 - 20 of 29 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

Explain about session? Where it runs & what are different types of session handling?

Asked By: kunnathsree | Asked On: Mar 1st, 2006

Answered by: Raji on: Feb 16th, 2013

Explain about session in detail with example

Answered by: Atul on: Dec 7th, 2006

Yup the comment is right. HTTP is a stateless protocol so we use session to identify the user.

Print the number in rverse order

Asked By: bhaskarreddy84 | Asked On: Jul 9th, 2012

How can I print the numbers in descending order without using looping structure in PHP/Javascript

Answered by: Satya on: Nov 14th, 2012

Code
  1. function reverse(str){
  2.     return str.split("").reverse().join("");
  3. }

Marquee tag XML

Asked By: Ayush sharma | Asked On: Oct 17th, 2011

Is XML runs on HTML like Javascript or not & also can I use tag in XML if yes then how

How do you call function in Javascript?

Asked By: parthoaccy | Asked On: May 5th, 2008

Answered by: Ranjan Kumar on: Sep 22nd, 2011

Code
  1.  
  2. function CollFunction()
  3. {
  4. alert("ok")
  5. }
  6.  

Answered by: salijaffar on: Feb 27th, 2009

Just write the name of the function and a pair of small brackets then semi-colon after it.
example.
functionName();

How do you get field value in Javascript?

Asked By: parthoaccy | Asked On: May 5th, 2008

Answered by: ram on: Aug 25th, 2011

document.forms[0].MyField

Answered by: Cool Swadi on: Dec 30th, 2009

You can use either

1. document.getElementById("").value

or

2. document.forms[0]..value

How to use email validation in Java script.Like user can't enter invalid email address?

Asked By: mrbaliram | Asked On: Feb 1st, 2006

Star Read Best Answer

Editorial / Best Answer

Answered by: bicu

View all questions by bicu   View all answers by bicu

Member Since Sep-2005 | Answered On : Feb 2nd, 2006

First of all, here is the javascript function that tests if an email address is valid.
It checks for a lot of things: to see if the email contains a "@" sign and a dot, checks to see if the @ is before the dot, and so on.

<script>
function isMail(str)
{
   var at="@";
   var dot=".";
   var lat=str.indexOf(at);
   var lstr=str.length;
   var ldot=str.indexOf(dot);
   if (str.indexOf(at)==-1) return false;
   if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
   if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
   if (str.indexOf(at,(lat+1))!=-1) return false; if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
   if (str.indexOf(dot,(lat+2))==-1) return false;
   if (str.indexOf(" ")!=-1) return false;
   return true;
}

// the next function will be used to validate the form. I made this as a separate function because you might want to validate more fields.
function validate_form()
{
   if (!isMail(document.form1.mail.value))
   {
      alert("Please enter a valid email address");
      document.form1.mail.focus();
      return false;
   }
   // if the value entered is not a valid email address, 
   // we show a message, focus on the field and return false.
   // returning false will make sure the form is not submitted

   // if we got here, it means the email address is valid
   return true;
   // return true means that the form is submitted.
}

</script>

After placing this function in the code, here is what you need to put in the form.

Let's say the form only has the email address and a submit button.

<form action="/" method="post" onsubmit="return validate_form()" name="form1">
<input type="text" name="email" value="">
<input type="submit" name="submit_button" value="continue">
</form>

Answered by: Ravi Maggon on: May 16th, 2011

<html>   <head>     <script type="text/javascript">   function check()    {     var filter=/^[a-zA-Z0-...

Answered by: SwapnilSwapnil on: Sep 7th, 2009

There are many varieties of email validation. This one is simple, but effective.

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 }

Render HTML inside div element

Asked By: tallman07 | Asked On: Aug 10th, 2010

Write a one line code to render HTML inside a div element.

Answered by: hari_nowayout on: Mar 25th, 2011

in case of html, this can be done by 


document.getElementByID("divname").innerHTML("

write any html tags u want here

");


in case of JQuery, it is done by 

$("#divname").html("

any html

");


Javascript memory leak

Asked By: bibhashmishra | Asked On: Nov 9th, 2010

What are the causes for memory leak in respect of Javascript?

Web page redirect

Asked By: tallman07 | Asked On: Aug 10th, 2010

What are the three ways of redirecting a web page logincheck.PHP to logged.PHP using1. HTML2. Javascript3. PHP

Answered by: kedarPhp on: Sep 2nd, 2010

At the starting of the logincheck.php page you can add the javascript code as follow

Code
  1. <script language='javascript'>
  2. you can use one of the following
  3. 1:location.href='login.php';
  4. 2:window.location='login.php';
  5. 3:window.location.href='login.php';
  6. </script>
  7. <?php
  8. exit();  //write the exit to exit the current php page execution
  9. ?>

Script to check every character

Asked By: karthikeyanakka | Asked On: Mar 19th, 2008

Write a code to get the text box data and to check each and every char?

Answered by: vasanth.kvj on: Nov 23rd, 2009

function numvalid(a) {  var numStr="1234567890"; var thisChar; var counter=0; for(var i=0; i < a.length; i++) { thisChar=a.substring(i,i+1); if(numStr.indexOf(thisChar...

Answered by: princesh on: Nov 18th, 2008

Read the input text
Check the length of the string
Substract the length by one
And then keeping doing this till end of the string.

Javascript and jscript?

Asked By: azizmayana | Asked On: Oct 22nd, 2008

How and in what ways does Javascript differ from jscript?

Answered by: imedvedeva on: Feb 26th, 2009

The biggest difference now between Javascript and JScript are all of the additional commands that JScript supports that allow access to activeX and the local computer. These commands are intended for ...

Redirecting a page

Asked By: Rajanikanththota | Asked On: Jul 23rd, 2008

How to redirect a page using Javascript

Answered by: brijbhushansh on: Oct 13th, 2008

window.location="filename"

Answered by: chenw2000 on: Aug 2nd, 2008

use location.href = "new page URL"

Write sample code for pagination using Java script.

Asked By: asuh | Asked On: Sep 20th, 2006

Answered by: RAJEEVRM on: Sep 12th, 2008

//Javscript code pagination.js file===========function Pager(tableName, itemsPerPage) {    this.tableName = tableName;    this.itemsPerPage = itemsPerPage;  &nb...

What is the difference between Java and Java script?

Asked By: annapurna | Asked On: Oct 4th, 2006

Answered by: designersub on: Sep 2nd, 2008

Javascript is client side language and Java is serverside language

Answered by: Divya on: Nov 22nd, 2007

Java script does support inheritance. It is an object oriented language, not object based

How to prevent a window not to be clicked or selected any way in Java script?

Asked By: anil | Asked On: Sep 25th, 2006

Answered by: designersub on: Sep 2nd, 2008

<script language="javascript"> function noClick(e) {  if (navigator.appName == 'Netscape' && e.which == 3) {      alert("no righ...

How do you check validations in Javascript?

Asked By: parthoaccy | Asked On: May 5th, 2008

Answered by: IRS786 on: Aug 10th, 2008

for example form validation:<html><head><script type="javascript">function formvalidation(form){if (nonempty(form.req1)){if (nonempty(form.req2)){return true;}}return false...

How do you restrict user not to copy web page in Java script ?

Asked By: parthoaccy | Asked On: May 5th, 2008

Answered by: raghavakrao on: Aug 9th, 2008

By disabling right click we can restrict user not to copy webpage sourcecode.

How to validate a email-address, in form using Javascript?

Asked By: Devika.N | Asked On: May 10th, 2007

Answered by: Rajanikanththota on: Jul 23rd, 2008

var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/; var address = document.form1.email.value; if(reg.test(address) == false) { alert('Invalid Email Address'); document.form1.email.focus(); return false; }

Answered by: basetutor on: May 10th, 2007

Simply cut and paste the below code into the <body> section of your page. Itcontains a form with one box that is checked for "email validity". You can add in more form elements into th...

Implement timer control

Asked By: sathiyarose | Asked On: Jun 25th, 2008

How to implement timer control in Javascript

Answered by: vijayan.nat on: Jul 22nd, 2008

set Timedout("alert('5 seconds')",5000);

will display display alert box after 5 seconds

Answered by: rakeshingle on: Jul 7th, 2008

using setTimeout() function u can implement timer in javascript.

How will you insert data into db2 using Javascript?

Asked By: ram | Asked On: Oct 9th, 2007

Answered by: keats on: Jun 26th, 2008

Using J Query

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.