Git Product home page Git Product logo

javascript's Issues

Email validation

<title>validate email</title> <script language="javascript" type="text/javascript"> function validate(){ if(document.f.email.value==''){ fail('Email missing'); return; } else if(document.f.email.value.indexOf('@')==-1){ fail('NO @ in the email'); return; } else{ var addr=document.f.email.value.split('@'); if(addr[0].length<1){ fail('User address absent'); } else if(addr[1].indexOf('.')== -1){ fail('not dot'); } else if(addr[1].length<3){ fail('Domain incorrect'); //eg "[email protected]" }else{ document.f.submit(); } } }//validate function fail(msg){ alert('Email error:'+msg); } </script>

booking form

Email:

Data type using Typeof

<title>data types 2 </title> <script languaje="javascript" type="text/javascript"> var a=0.06; var b="This is JavaScript"; var c=false; document.write(typeof a + "
" + typeof b + "
"+typeof c); console.log(typeof a + "\n"+typeof b +"\n"+ typeof c); </script>

Changing background color document.fgColor

<title>Changing background color</title> <script languaje="javascript" type="text/javascript"> function poll(){ for(var i=0;i<=document.f.rad1.length;i++){ if(document.f.rad1[i].checked){ document.fgColor=document.f.rad1[i].value; } } } </script>

Changing background Color

white silver skyblue

Nested fuctions

<title> multiple function: Building Calculator function</title> <script language="javascript" type="text/javascript"> function addSquares(a,b){ function square(x){ return x*x; } return square (a)+square(b); } document.write(addSquares(3,4)); </script>

document.wordcount....

<title> </title> <script languaje="javascript" type="text/javascript"> function countit(){ var formcontent=document.wordcount.wordcount2.value; var content=formcontent.split(" "); document.wordcount.wordcount3.value=content.length; } </script> <textarea rows="12" name="wordcount2" cols="39" wrap="virtual"></textarea>

library

function myFunction(){
var fruits=["Banana","Orange","Apple","Mango"];
var x=document.getElementById("demo");
x.innerHTML=fruits.join();
}

Unobtrusive JavaScript

<title> oJb5</title> <script language="javascript" type="text/javascript" src="popstuff.js"></script>
The links below are openedend in a pop up. The script for the popup is in the external JavaScript file

page1
page2
page3

Convert Element to String

function myFunction(){
var fruits=["Banana","Orange","Apple","Mango"];
var x=document.getElementById("demo");
x.innerHTML=fruits.join();
}

A basic search.list()

I am teaching myself how to work with APIs.

// Helper function to display JavaScript value on HTML page.
function showResponse(response) { var responseString = JSON.stringify(response, '', 2); document.getElementById('response').innerHTML += responseString; }
// Called automatically when JavaScript client library is loaded.
function onClientLoad() { gapi.client.load('youtube', 'v3', onYouTubeApiLoad); }

// Called automatically when YouTube API interface is loaded
function onYouTubeApiLoad() { // This API key is intended for use only in this lesson. // See https://goo.gl/PdPA1 to get a key for your own applications. gapi.client.setApiKey('AIzaSyCR5In4DZaTP6IEZQ0r1JceuvluJRzQNLE'); search(); }

// Use the JavaScript client library to create a search.list() API call.
function search() { var request = gapi.client.youtube.search.list({ part: 'id' }); // Send the request to the API server, // and invoke onSearchRepsonse() with the response. request.execute(onSearchResponse); }
// Called automatically with the response of the YouTube API request.
function onSearchResponse(response) { showResponse(response); }

The html file

`

<script src="search.js" type="text/javascript"></script>
<script src="https://apis.google.com/js/client.js?onload=onClientLoad" type="text/javascript"> </script>



`

getAttribute

window.onload=prepareLinks;
function prepareLinks(){
var links =document.getElementsByTagName("a");
for(var i=0;i<=links.length;i++){
if(links[i].getAttribute("class")=="popup"){
links[i].onclick=function(){
popUp(this.getAttribute("href"));
return false;

            }

        }

    }

}
function popUp(winURL){
window.open(winURL,"popup","width=320,height=480");
}

Playing with styling strings

<title> Styling strings </title> <script language= “javascript” type="text/javascript"> var txt = "Hello World!"; document.write("

Big: " + txt.big() + "

"); document.write("

Small: " + txt.small() + "

"); document.write("

Bold: " + txt.bold() + "

"); document.write("

Italic: " + txt.italics() + "

"); document.write("

Fixed: " + txt.fixed() + "

"); document.write("

Strike: " + txt.strike() + "

"); document.write("

Fontcolor: " + txt.fontcolor("green") + "

"); document.write("

Fontsize: " + txt.fontsize(6) + "

"); document.write("

Subscript: " + txt.sub() + "

"); document.write("

Superscript: " + txt.sup() + "

"); document.write("

Link: " + txt.link("http://www.w3schools.com") + "

"); document.write("

Blink: " + txt.blink() + " (does not work in IE, Chrome, or Safari)

"); </script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.