Verification IP on an example

  Windows usually feel the IP input box with a good, if the website can also achieve certain things that feel so cool.    Core code as follows: 

  <script Language="javascript"> 
  Function outStr () ( 
  If (document.all.ip1.value> 0 & & document.all.ip2.value> 0 & & document.all.ip3.value> 0 & & document.all.ip4.value> 0) ( 
  Alert ( "you enter the IP address:" document.all.ip1.value + + "." Document.all.ip2.value + + "." Document.all.ip3.value + + "." + Document. all.ip4.value); 
  ) / / End if 
  ) / / End 
  Function moveRight (obj) ( 
  Id = parseInt (obj.name.substr (2,1)) 
  If (id <4) ( 
  Eval ( "document.all.ip" + (id +1) +. "Focus ()"); 
  Else () 
  OutStr (); 
  ) / / End if 
  ) 
  Function moveLeft (obj) ( 
  Id = parseInt (obj.name.substr (2,1)) 
  If (id> 1) ( 
  Eval ( "document.all.ip" + (id -1) +. "Focus ()"); 
  ) / / End if 
  ) / / End if 
  Function Keypress (obj) ( 
  Var objInput = obj; 
  Window.event.keyCode = cod; 

  If (cod == 46 & & (obj.value). Length> 0) (/ / If by the "." And with a character, a right move 
  Window.event.keyCode = 0; 
  MoveRight (obj); 
  ) Else if ((obj.value). Length == 2 & & (cod> = 48) & & (cod <= 57 )){// If the number keys and enough 2 
  If (cod <58) (/ / 
  Obj.value obj.value * = 10 + cod - 48; 
  ) / / End if 
  Window.event.keyCode = 0; 
  MoveRight (obj); 
  ) Else (/ / input judgement is not just numbers 
  If (! (((Cod> = 48) & & (cod <= 57)) | | (cod == 13) | | (cod == 37) | | (cod == 39))) ( 
  Window.event.keyCode = 0; 
  ) / / End if 
  ) / / End if 
  ) / / End function keydown 
  Function getCaretPos (obj) ( 
  Var currentRange = document.selection.createRange (); 
  Var workRange = currentRange.duplicate (); 
  Obj.select (); 
  Var allRange = document.selection.createRange (); 
  Var len = 0; 
  While (workRange.compareEndPoints ( "StartToStart" allRange)> 0) ( 
  WorkRange.moveStart ( "character", -1); 
  Len + +; 
  ) 
  CurrentRange.select (); 
  Return len; 
  ) / / End 
  Function KeyDown (obj) ( 
  Window.event.keyCode = cod; 
  I = getCaretPos (obj); / / cursor position 
  N = obj.value.length; / / characters in length 

  If (cod == 37 & & i == 0) (/ / cursor backspace 
  MoveLeft (obj); 
  ) Else if (cod == 39 & & i> = n) ( 
  MoveRight (obj); 
  ) Else if (cod == 8 & (obj.value == "" | | i == 0)) ( 
  MoveLeft (obj); 
  ) / / End if 
  ) / / End 
  Function checkDate (obj, max_num) ( 
  If (obj.value> max_num | | obj.value <0) ( 
  Window.event.keyCode = 0; 
  Alert (obj.value + "is null and void, only the importation of 0 to" max_num + + "between the number."); 
  Obj.value = max_num; 
  Obj.focus (); 
  Obj.select (); 
  ) / / End if 
  ) / / End 
  </ Script> 

  Testing Website: http://www.yemaweb.com/test/ipv1.0.htm 
  All source code in the Web page, there is no encryption and do not want to use when removed from the source. 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “Verification IP on an example”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.