Explain about session? Where it runs & what are different types of session handling?
Print the number in rverse order
How can I print the numbers in descending order without using looping structure in PHP/Javascript
Code
function reverse(str){ return str.split("").reverse().join(""); }
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?
Code
function CollFunction() { alert("ok") }
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?
document.forms[0].MyField
You can use either
1. document.getElementById("
or
2. document.forms[0].
How to use email validation in Java script.Like user can't enter invalid email address?
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>
<html> <head> <script type="text/javascript"> function check() { var filter=/^[a-zA-Z0-...
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
Write a one line code to render HTML inside a div element.
in case of html, this can be done by
write any html tags u want here
");any html
");What are the causes for memory leak in respect of Javascript?
What are the three ways of redirecting a web page logincheck.PHP to logged.PHP using1. HTML2. Javascript3. PHP
At the starting of the logincheck.php page you can add the javascript code as follow
Code
<script language='javascript'> you can use one of the following 1:location.href='login.php'; 2:window.location='login.php'; 3:window.location.href='login.php'; </script> <?php exit(); //write the exit to exit the current php page execution ?>
Script to check every character
Write a code to get the text box data and to check each and every char?
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...
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.
How and in what ways does Javascript differ from jscript?
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 ...
How to redirect a page using Javascript
window.location="filename"
use location.href = "new page URL"
Write sample code for pagination using Java script.
//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?
Javascript is client side language and Java is serverside language
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?
<script language="javascript"> function noClick(e) { if (navigator.appName == 'Netscape' && e.which == 3) { alert("no righ...
How do you check validations in Javascript?
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 ?
By disabling right click we can restrict user not to copy webpage sourcecode.
How to validate a email-address, in form using Javascript?
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; }
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...
How to implement timer control in Javascript
set Timedout("alert('5 seconds')",5000);
will display display alert box after 5 seconds
using setTimeout() function u can implement timer in javascript.
How will you insert data into db2 using Javascript?
Using J Query
Explain about session in detail with example
Yup the comment is right. HTTP is a stateless protocol so we use session to identify the user.