fortoma eikonas

Κώδικας, πληροφορίες, ερωτήσεις και απαντήσεις σχετικές με την JavaScript.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
kingbill
Δημοσιεύσεις: 244
Εγγραφή: 19 Νοέμ 2005 15:06

fortoma eikonas

Δημοσίευση από kingbill » 16 Μάιος 2007 22:12

exo ena text field to opoio otan tha grafo kati na mou efanizetai mia eikona
ton elegxo ton kanei kanonika alla den fortonei tin eikoma
sas deino kai ton kodika

Κώδικας: Επιλογή όλων

<form name="form">
	<body onload="document.getElementById&#40;'password'&#41;.focus&#40;&#41;;">
	Enter your password here&#58;
	<input onkeyup="check&#40;this.value&#41;;" type="password" name="password" id="password" >
	<img src="images/tooshort.jpg" name="strength"id="strength" alt="" />

<script type="text/javascript">


var minpwlength = 4;
var fairpwlength = 7;

var STRENGTH_SHORT = 0;  // less than minpwlength 
var STRENGTH_WEAK = 1;   // less than fairpwlength

img0 = new Image&#40;&#41;; 
img0.src = "images/tooshort.jpg";

img1 = new Image&#40;&#41;;
img1.src = "images/fair.jpg";

var strengthlevel = 0;

var strengthimages = Array&#40; img0.src, img1.src, img2.src, img3.src&#41;;

	function check&#40;pw&#41; 
	&#123;
	 
	 	if &#40;!istoosmall&#40;pw&#41;&#41; 
	 	&#123;
 			strengthlevel = STRENGTH_SHORT;
	 	&#125;
		else 
			if&#40;!isfair&#40;pw&#41;&#41;
			&#123; 
				strengthlevel = STRENGTH_WEAK;					
			&#125;
		  document.getElementById&#40;'strength'&#41;.src = strengthimages&#91;strengthlevel&#93;;				 	
	&#125;//function check&#40;pw&#41; 
	
	function istoosmall&#40;pw&#41;
	&#123;
		if &#40;pw.length < minpwlength&#41;
		&#123;
			return false;
		&#125;
		else
		&#123;
			return true;
		&#125;
	&#125;//	function istoosmall&#40;pw&#41;
	function isfair&#40;pw&#41;
	&#123;
		if &#40;pw.length < fairpwlength&#41;
		&#123;
			return false;
		&#125;
		else
		&#123;
			return true;
		&#125;
	&#125;//	function isfair&#40;pw&#41;	

</script>
</body>	
</form>


Άβαταρ μέλους
Alice_Cooper
Δημοσιεύσεις: 1947
Εγγραφή: 11 Μάιος 2007 00:33
Τοποθεσία: Ioannina
Επικοινωνία:

fortoma eikonas

Δημοσίευση από Alice_Cooper » 29 Μάιος 2007 19:58

pira to diko sou kai to enosa me ena etoimo pou exei to dreamwaver
gia rollover imag
(to paradexome varethika na skefto :p)
exei kapoia perita o code lipon an thes katharise ton
doulevei omos

Κώδικας: Επιλογή όλων

<script type="text/JavaScript">
<!--
function MM_swapImgRestore&#40;&#41; &#123; //v3.0
  var i,x,a=document.MM_sr; for&#40;i=0;a&&i<a.length&&&#40;x=a&#91;i&#93;&#41;&&x.oSrc;i++&#41; x.src=x.oSrc;
&#125;

function MM_preloadImages&#40;&#41; &#123; //v3.0
  var d=document; if&#40;d.images&#41;&#123; if&#40;!d.MM_p&#41; d.MM_p=new Array&#40;&#41;;
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for&#40;i=0; i<a.length; i++&#41;
    if &#40;a&#91;i&#93;.indexOf&#40;"#"&#41;!=0&#41;&#123; d.MM_p&#91;j&#93;=new Image; d.MM_p&#91;j++&#93;.src=a&#91;i&#93;;&#125;&#125;
&#125;

function MM_findObj&#40;n, d&#41; &#123; //v4.01
  var p,i,x;  if&#40;!d&#41; d=document; if&#40;&#40;p=n.indexOf&#40;"?"&#41;&#41;>0&&parent.frames.length&#41; &#123;
    d=parent.frames&#91;n.substring&#40;p+1&#41;&#93;.document; n=n.substring&#40;0,p&#41;;&#125;
  if&#40;!&#40;x=d&#91;n&#93;&#41;&&d.all&#41; x=d.all&#91;n&#93;; for &#40;i=0;!x&&i<d.forms.length;i++&#41; x=d.forms&#91;i&#93;&#91;n&#93;;
  for&#40;i=0;!x&&d.layers&&i<d.layers.length;i++&#41; x=MM_findObj&#40;n,d.layers&#91;i&#93;.document&#41;;
  if&#40;!x && d.getElementById&#41; x=d.getElementById&#40;n&#41;; return x;
&#125;

function MM_swapImage&#40;&#41; &#123; //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for&#40;i=0;i<&#40;a.length-2&#41;;i+=3&#41;
   if &#40;&#40;x=MM_findObj&#40;a&#91;i&#93;&#41;&#41;!=null&#41;&#123;document.MM_sr&#91;j++&#93;=x; if&#40;!x.oSrc&#41; x.oSrc=x.src; x.src=a&#91;i+2&#93;;&#125;
&#125;
//-->
var minpwlength = 4;
var fairpwlength = 7;

var STRENGTH_SHORT = 0;  // less than minpwlength
var STRENGTH_WEAK = 1;   // less than fairpwlength
var strengthlevel = 0;
var strengthimages = Array&#40; img0.src, img1.src, img2.src, img3.src&#41;;

   function check&#40;pw&#41;
   &#123;
   
       if &#40;!istoosmall&#40;pw&#41;&#41;
       &#123;
          strengthlevel = STRENGTH_SHORT;
		  MM_swapImgRestore&#40;&#41;;
       &#125;
      else
         if&#40;!isfair&#40;pw&#41;&#41;
         &#123;
            strengthlevel = STRENGTH_WEAK;
			MM_swapImage&#40;'Image2','','IMAGEOK.jpg',1&#41;            
         &#125;
        document.getElementById&#40;'strength'&#41;.src = strengthimages&#91;strengthlevel&#93;;                
   &#125;//function check&#40;pw&#41;
   
   function istoosmall&#40;pw&#41;
   &#123;
      if &#40;pw.length < minpwlength&#41;
      &#123;
         return false;
      &#125;
      else
      &#123;
         return true;
      &#125;
   &#125;//   function istoosmall&#40;pw&#41;
   function isfair&#40;pw&#41;
   &#123;
      if &#40;pw.length < fairpwlength&#41;
      &#123;
         return false;
      &#125;
      else
      &#123;
         return true;
      &#125;
   &#125;//   function isfair&#40;pw&#41;   

</script>

   <style type="text/css">
<!--
#Layer1 &#123;
	position&#58;absolute;
	left&#58;11px;
	top&#58;45px;
	width&#58;367px;
	height&#58;114px;
	z-index&#58;1;
&#125;
-->
   </style>
   <body onLoad="document.getElementById&#40;'password'&#41;.focus&#40;&#41;;MM_preloadImages&#40;'IMAGEOK.jpg'&#41;">
   <form name="form">
   Enter your password here&#58;
   <input onKeyUp="check&#40;this.value&#41;;" type="password" name="password" id="password" >
   </form>

<img src="IMAGERR.jpg" name="Image2" border="0" id="Image2" />

</body>

Απάντηση

Επιστροφή στο “JavaScript και Frameworks”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 1 επισκέπτης