ࡱ> #` E+bjbjmm .hE#pppppppUUUU<UvljV4Y4Y4Y4YZZZkkkkkkk$mhHpzlpZZZZZlpp4Y4Y0lhahahaZZp4Yp4YkhaZkhahadpp-d4YV  UL_<dQdFl0vl%dp`p-dpp-d$Z"1ZhaIZ]ZZZZllRaZZZvlZZZZ066pppppp http://www.w3schools.com/js/default.asp JavaScript Form Validation JavaScript can be used to validate input data in HTML forms before sending off the content to a server. Form data that typically are checked by a JavaScript could be: has the user left required fields empty? has the user entered a valid e-mail address? has the user entered a valid date? has the user entered text in a numeric field?  Required Fields The function below checks if a required field has been left empty. If the required field is blank, an alert box alerts a message and the function returns false. If a value is entered, the function returns true (means that data is OK): function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") {alert(alerttxt);return false} else {return true} } }The entire script, with the HTML form could look something like this:
Email:
  E-mail Validation The function below checks if the content has the general syntax of an email. This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign: function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@") dotpos=value.lastIndexOf(".") if (apos<1||dotpos-apos<2) {alert(alerttxt);return false} else {return true} } }The entire script, with the HTML form could look something like this:
Email:
 JavaScript split() Method  HYPERLINK "http://www.w3schools.com/jsref/jsref_obj_string.asp"  INCLUDEPICTURE "http://www.w3schools.com/images/btn_exit.gif" \* MERGEFORMATINET   Definition and Usage The split() method is used to split a string into an array of strings. Syntax stringObject.split(separator, howmany) ParameterDescriptionseparatorRequired. Specifies the character, regular expression, or substring that is used to determine where to split the stringhowmanyOptional. Specify how many times split should occur. Must be a numeric value  Tips and Notes Note: If an empty string ("") is used as the separator, the string is split between each character.  Example In this example we will split up a string in different ways: The output of the code above will be: How,are,you,doing,today? H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,? How,are,you  Try-It-Yourself Demos  HYPERLINK "http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_split" \t "_blank" split() How to use split() to split up a string. Example for Split program: The Above program produces the following output on the screen: How,are,you,doing,today? H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,? How,are,you JavaScript String Object Reference  String Object Methods FF: Firefox, N: Netscape, IE: Internet Explorer MethodDescriptionFFNIE HYPERLINK "http://www.w3schools.com/jsref/jsref_anchor.asp" \t "_top" anchor()Creates an HTML anchor123 HYPERLINK "http://www.w3schools.com/jsref/jsref_big.asp" \t "_top" big()Displays a string in a big font123 HYPERLINK "http://www.w3schools.com/jsref/jsref_blink.asp" \t "_top" blink()Displays a blinking string12 HYPERLINK "http://www.w3schools.com/jsref/jsref_bold.asp" \t "_top" bold()Displays a string in bold123 HYPERLINK "http://www.w3schools.com/jsref/jsref_charAt.asp" \t "_top" charAt()Returns the character at a specified position123 HYPERLINK "http://www.w3schools.com/jsref/jsref_charCodeAt.asp" \t "_top" charCodeAt()Returns the Unicode of the character at a specified position144 HYPERLINK "http://www.w3schools.com/jsref/jsref_concat_string.asp" \t "_top" concat()Joins two or more strings144 HYPERLINK "http://www.w3schools.com/jsref/jsref_fixed.asp" \t "_top" fixed()Displays a string as teletype text123 HYPERLINK "http://www.w3schools.com/jsref/jsref_fontcolor.asp" \t "_top" fontcolor()Displays a string in a specified color123 HYPERLINK "http://www.w3schools.com/jsref/jsref_fontsize.asp" \t "_top" fontsize()Displays a string in a specified size123 HYPERLINK "http://www.w3schools.com/jsref/jsref_fromCharCode.asp" \t "_top" fromCharCode()Takes the specified Unicode values and returns a string144 HYPERLINK "http://www.w3schools.com/jsref/jsref_indexOf.asp" \t "_top" indexOf()Returns the position of the first occurrence of a specified string value in a string123 HYPERLINK "http://www.w3schools.com/jsref/jsref_italics.asp" \t "_top" italics()Displays a string in italic123 HYPERLINK "http://www.w3schools.com/jsref/jsref_lastIndexOf.asp" \t "_top" lastIndexOf()Returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string123 HYPERLINK "http://www.w3schools.com/jsref/jsref_link.asp" \t "_top" link()Displays a string as a hyperlink123 HYPERLINK "http://www.w3schools.com/jsref/jsref_match.asp" \t "_top" match()Searches for a specified value in a string144 HYPERLINK "http://www.w3schools.com/jsref/jsref_replace.asp" \t "_top" replace()Replaces some characters with some other characters in a string144 HYPERLINK "http://www.w3schools.com/jsref/jsref_search.asp" \t "_top" search()Searches a string for a specified value144 HYPERLINK "http://www.w3schools.com/jsref/jsref_slice_string.asp" \t "_top" slice()Extracts a part of a string and returns the extracted part in a new string144 HYPERLINK "http://www.w3schools.com/jsref/jsref_small.asp" \t "_top" small()Displays a string in a small font123 HYPERLINK "http://www.w3schools.com/jsref/jsref_split.asp" \t "_top" split()Splits a string into an array of strings144 HYPERLINK "http://www.w3schools.com/jsref/jsref_strike.asp" \t "_top" strike()Displays a string with a strikethrough123 HYPERLINK "http://www.w3schools.com/jsref/jsref_sub.asp" \t "_top" sub()Displays a string as subscript123 HYPERLINK "http://www.w3schools.com/jsref/jsref_substr.asp" \t "_top" substr()Extracts a specified number of characters in a string, from a start index144 HYPERLINK "http://www.w3schools.com/jsref/jsref_substring.asp" \t "_top" substring()Extracts the characters in a string between two specified indices123 HYPERLINK "http://www.w3schools.com/jsref/jsref_sup.asp" \t "_top" sup()Displays a string as superscript123 HYPERLINK "http://www.w3schools.com/jsref/jsref_toLowerCase.asp" \t "_top" toLowerCase()Displays a string in lowercase letters123 HYPERLINK "http://www.w3schools.com/jsref/jsref_toUpperCase.asp" \t "_top" toUpperCase()Displays a string in uppercase letters123 HYPERLINK "http://www.w3schools.com/jsref/jsref_toSource_string.asp" toSource()Represents the source code of an object14- HYPERLINK "http://www.w3schools.com/jsref/jsref_valueOf_string.asp" valueOf()Returns the primitive value of a String object124  String Object Properties PropertyDescriptionFFNIE HYPERLINK "http://www.w3schools.com/jsref/jsref_constructor_string.asp" constructorA reference to the function that created the object144 HYPERLINK "http://www.w3schools.com/jsref/jsref_length_string.asp" lengthReturns the number of characters in a string123 HYPERLINK "http://www.w3schools.com/jsref/jsref_prototype_string.asp" prototypeAllows you to add properties and methods to the object124 (C " # i ABD]^_Ѽћ헏ѼjZjhoB* CJOJQJaJph (jhoB* CJOJQJUaJph hoB*CJOJQJaJphhoCJaJho(j$hoB*CJOJQJUaJphhoB*CJaJph(jhoB*CJOJQJUaJphhoB*CJOJQJaJphhoB*CJaJphhoCJaJhwhwCJaJ (C B f  " $Ifgdo & Fdd[$\$gdogdogdoE+" # i p w  # % ' }}}}}}}}}}}}$Ifgdowkd$$If!  0634` abp ' H J Z \  , ^ $If  "@\~yysssssss$Ifgdogdogdowkd`$$If!  0634` abp \} 13@BZ}gdowkd$$If!  0634` abp $IfZxA`bdnv})19A$IfABCD^W^||wrwl$Ifgdogdogdogdowkd$$If!  0634` abp W^ !vwxyz|iTEho5B*CJ\aJph(j* hoB*CJOJQJUaJph%ho5B*CJOJQJ\aJphhoB*CJaJphhoB*CJaJphhoCJaJ(jhoB*CJOJQJUaJphhoB*CJOJQJaJph(jhoB*CJOJQJUaJph(jhoB* CJOJQJUaJph (jHhoB* CJOJQJUaJph }}$Ifgdowkd$$If!  0634` abp  hbb$Ifkd|$$If0! 0634` abp !)vhbb$Ifkdf$$If0! 0634` abpvwxz4Thcc^Yc^YS$IfgdogdogdokdH $$If0! 0634` abp 4qrsturǻǻۦӕǕLJ|tdO(j hoB*CJOJQJUaJphhoB*CJOJQJaJphhoCJaJhehomHsHhoho0JCJaJ jhoB*CJUaJph(j hoB*CJOJQJUaJphhoB*CJaJphhoB*CJaJphhoCJaJhoB*CJOJQJaJph(j hoB*CJOJQJUaJphTw5eq}gdowkdb $$If!  0634` abp $If qrsu4;BCcd~ywgdogdogdowkd& $$If!  0634` abp XY!-0256Fft$Ifgdogdogdogdo567~bcjkFGOP$%&tu}~ɴɴɴɴɴɴɴɴho0JCJOJQJaJhoB*CJOJQJaJph(jhoB*CJOJQJUaJphhoCJaJ%ho5B*CJOJQJ\aJphhoB*CJaJphho5B*CJ\aJph;lQFf0FfFfFf$If "$%tFf,Ff(Ff%Ff"$IfFf_fgrs%&'tu tuv: ; H I !!#!$!L!M!N!!!!!!!!""#"$"k"l"m""""""""<#=#hoCJaJhoB*CJOJQJaJphho0JCJOJQJaJ(jhoB*CJOJQJUaJphN!#%&nprtuJ Ff8Ff5Ffy2FfJ/$If %!F!H!J!L!M!!!!!!!%"e"g"i"k"l""""""FfEFfdBFf5?Ff<$If""F####### $ $$$$c$$$$$$$ %%%%%a%Ff~UFfORFf OFfK$IfFfH=#D#E########$$$Y$Z$a$b$$$$$$$$%%%Y%Z%_%`%%%%%%%%*&+&,&v&w&&&&&&''''A'B'C''''''''(((()(W(X(Y((((((((!)")+)hoCJaJhoB*CJOJQJaJph(jhoB*CJOJQJUaJphho0JCJOJQJaJNa%%%%%%%$&&&(&*&+&&&&&&&';'='?'A'B''''Ff:bFf _Ff[FfX$If''''*(Q(S(U(W(X(((((((-)\)^)`)b)c)d)f)))gdogdoFfnFfkFfhFfie$If+),)b)c)d)e)f)))))))))/*0*1*u*v*|*}******++C+D+E+۾ӫәhoho0JCJOJQJaJ%ho5B*CJOJQJ\aJph(jphoB*CJOJQJUaJphhoCJaJhoB*CJOJQJaJph(jhoB*CJOJQJUaJph))))))))*+*-*/*0*~******+=+?+A+C+D+E+gdoFf^|Ff/yFfvFfr$If,1h/ =!"#$% DdP  3 3"88$$If!vh5!#v!:V  06,5/ 34 ` p $$If!vh5!#v!:V  06,5/ 34 ` p DdP  3 3"88$$If!vh5!#v!:V  06,5/ 34 ` p $$If!vh5!#v!:V  06,5/ 34 ` p Dd[Ed   c @A btn_exitBackb AJR=j\ ,~n AJR=j\ ,PNG  IHDRdp PLTEٹtRNS0JbKGDH cmPPJCmp0712Om[IDAT(cXdh`8/õH( 0AL2\p H2Z0V)(1)!YгA&%%(,B5 6\ .4=fIENDB`DdP  3 3"88$$If!vh5!#v!:V  06,5/ 34 ` p $$If!vh55#v#v:V 0655/ 34 ` p$$If!vh55#v#v:V 065/ 34 ` p$$If!vh55#v#v:V 065/ 34 ` pDdP  3 3"88DdP  3 3"88$$If!vh5!#v!:V  06,5/ 34 ` p $$If!vh5!#v!:V  06,5/ 34 ` p DdP  3 3"88DdP  3 3"88P$$If!vh555[5[5[#v#v#v[:V 2065~5 5/ 34 ` p2kd"$$Ifrt !~  20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kda$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdL!$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd{$$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd'$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd*$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd.$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd71$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdf4$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd7$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd:$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd=$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd"A$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdQD$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdG$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdJ$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kdM$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd Q$$Ifrt ! 20634` abp2@$$If!vh555[5[5[#v#v#v[:V 2065/ 34 ` p2kd*ph q E#h(CBf  "#ipw#%'HJZ\,^ "@\} 13@BZx A ` b d n v }  ) 1 9 A B C D ^  W ^ ! ) v w x z 4 T w 5eqrsu4;BCcdXY!-0256lQ "$%t!#%&nprtuJ%FHJLM%egiklF  c a$&(*+;=?AB* Q S U W X -!\!^!`!b!c!d!f!!!!!!!!!)"+"-"/"0"~""""""#=#?#A#C#D#G#0000 0 0 0 0000000000000 0 00000000000000000000000000000000 0 0000000000000000 0 0000000000000000000000000000000000 0 000000000 0 00 0 0 0 0 0 0 0 0 0000000000000 0 0000 0 000000000000000000000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"#) 1 9 A B ! v w qrsu;XY!-0256lQ "$%t!#%&nprtuJ%FHJLM%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@0(  B S  ?;Tl;i%%G#**G#9*urn:schemas-microsoft-com:office:smarttagsplace8*urn:schemas-microsoft-com:office:smarttagsCity '(2370=>FPX`qr~ "():DHem !/BFGTZ`ar|    D O ^ p | ! ( G Q T W X [ w 35:=BEJMVYbepV`dghkYprGMu{gpu;F & "!)!G#BBEfi\^46SX")Za  O U   T W 359<@dg\prG#333333333333333333333333\"@Zx C D ^  W T w 54CdYD#G#rG#b2=Ь#^`CJOJQJo(^`CJOJQJo(opp^p`CJOJQJo(@ @ ^@ `CJOJQJo(^`CJOJQJo(^`CJOJQJo(^`CJOJQJo(^`CJOJQJo(PP^P`CJOJQJo(b2=owe"#iA B ^ ! ) v w 4 qr!-0256lQ "$%t!#%&nprtuJ%FHJLM%egiklF  c a$&(*+;=?AB* Q S U W X -!\!^!`!b!c!!!!!!!!!)"+"-"/"0"~""""""#=#?#A#C#D#G#@E#P@UnknownGz Times New Roman5Symbol3& z Arial7&  Verdana?5 z Courier New;Wingdings"1hZZZC@C@!4d3#3#2HX ?o2JavaScript Form ValidationGanesanganesan Oh+'0  ( H T ` lxJavaScript Form ValidationGanesan Normal.dotganesan2Microsoft Office Word@G@nj @nj @nj C՜.+,D՜.+,X hp  Oakland University@3#' JavaScript Form Validation Titlet 8@ _PID_HLINKSA,[ i:http://www.w3schools.com/jsref/jsref_prototype_string.aspEf7http://www.w3schools.com/jsref/jsref_length_string.asp;mc<http://www.w3schools.com/jsref/jsref_constructor_string.asp"~`8http://www.w3schools.com/jsref/jsref_valueOf_string.asp8p]9http://www.w3schools.com/jsref/jsref_toSource_string.asp*CZ5http://www.w3schools.com/jsref/jsref_toUpperCase.asp5]W5http://www.w3schools.com/jsref/jsref_toLowerCase.asp5GT-http://www.w3schools.com/jsref/jsref_sup.aspZ/Q3http://www.w3schools.com/jsref/jsref_substring.aspmN0http://www.w3schools.com/jsref/jsref_substr.asp5UK-http://www.w3schools.com/jsref/jsref_sub.aspbH0http://www.w3schools.com/jsref/jsref_strike.aspY/E/http://www.w3schools.com/jsref/jsref_split.aspA:B/http://www.w3schools.com/jsref/jsref_small.aspV?6http://www.w3schools.com/jsref/jsref_slice_string.aspy<0http://www.w3schools.com/jsref/jsref_search.asp*B91http://www.w3schools.com/jsref/jsref_replace.aspB56/http://www.w3schools.com/jsref/jsref_match.asp~ 3.http://www.w3schools.com/jsref/jsref_link.asp1H05http://www.w3schools.com/jsref/jsref_lastIndexOf.asp;V-1http://www.w3schools.com/jsref/jsref_italics.asp$W*1http://www.w3schools.com/jsref/jsref_indexOf.asps'6http://www.w3schools.com/jsref/jsref_fromCharCode.aspk $2http://www.w3schools.com/jsref/jsref_fontsize.asp[1!3http://www.w3schools.com/jsref/jsref_fontcolor.aspL>/http://www.w3schools.com/jsref/jsref_fixed.aspW 7http://www.w3schools.com/jsref/jsref_concat_string.aspl4http://www.w3schools.com/jsref/jsref_charCodeAt.aspk0http://www.w3schools.com/jsref/jsref_charAt.aspw.http://www.w3schools.com/jsref/jsref_bold.aspB$/http://www.w3schools.com/jsref/jsref_blink.asp)A -http://www.w3schools.com/jsref/jsref_big.aspe 0http://www.w3schools.com/jsref/jsref_anchor.aspxAhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_split;b4http://www.w3schools.com/jsref/jsref_obj_string.asp  !"#$%&'()*+,-./012346789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstvwxyz{|}~Root Entry F  Data 5K~1TableupWordDocument.hSummaryInformation(DocumentSummaryInformation8CompObjq  FMicrosoft Office Word Document MSWordDocWord.Document.89q