Using this example JavaScript you can have a password entry field that contains the text "Enter Password". The text will go away when the user enters data. But if the leave the field blank it will go back to "Enter Password". This can be modified for use with any input field. Put the JavaScript below in the <head> section of your html page.
<script type="text/javascript">
function focus(el) {
if (el.defaultValue==el.value) el.value = ""
}
function blur(el) {
if (el.value == "") el.value = el.defaultValue;
}
</script>
The <input> tag looks like the one below. Note the onFocus and onBlur function calls.
<input type=text style="width: 120;" value="Enter Password"
onFocus="focus(this)" onBlur="blur(this)" name=password maxlength=10 autocomplete=off>
To see all the JavaScript and associated html that is required, do a view source while on the demo page.
- - Start Script Here - -
- - End Script Here - -
- - Start Script Here - -
- - End Script Here - -
<script type="text/javascript">
function focus(el) {
if (el.defaultValue==el.value) el.value = ""
}
function blur(el) {
if (el.value == "") el.value = el.defaultValue;
}
</script>
The <input> tag looks like the one below. Note the onFocus and onBlur function calls.
<input type=text style="width: 120;" value="Enter Password"
onFocus="focus(this)" onBlur="blur(this)" name=password maxlength=10 autocomplete=off>
Moving (bouncing) Image
You can have a moving (or bouncing) image on your web page. A great idea for a logo. Click this link to see it in action. If you resize the browser window it will automatically adjust to the new size. It will also randomly change direction so as not to get entrenched into a "pattern".To see all the JavaScript and associated html that is required, do a view source while on the demo page.
Get the most recent file date
When you need that most recent update date. You can use this script to get the most recent file date in a given directory. To use current directory, use "./" as the directory name.- - Start Script Here - -
<?PHP
$path = "directory";$globarray = glob($path);
if ($globarray)
foreach ($globarray as $filename)
if (filemtime($filename) >= $recentDate) $recentDate = filemtime($filename); $recentDate = date(" F d, Y",$recentDate);
echo $recentDate;?>- - End Script Here - -
Replace banned words
This script will replace banned words in the string $message with an * for each letter. You can use this when receiving POST data with text input. In this example the banned words are in a text file called words.dat (in the same directory as the script) with one banned word per line.- - Start Script Here - -
<?php
$words_array = file('words.dat');$words_array = str_replace("\n", "", $words_array);$words_array = str_replace("\r", "", $words_array);$word_stars = preg_replace( '/./','*',$words_array ); // replace every letter with a *$words_array = preg_replace( '/(.+)/','#\1#i',$words_array ); // put # delim around each word$message = preg_replace($words_array, $word_stars, $message);?>- - End Script Here - -
Comments
Post a Comment