form js

Upload: anonymous-rcmesfj5

Post on 08-Jul-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 form js

    1/3

    Infolet already wrote an article about log in form validation using JavaScript. In there, errormessages will show as alert boxes. In professional works, error messages in alert boxes arenot good.So this article contains a registration form validation with showing error messages in samepage using JavaScript.For this, an ‘id used to represent and display error messages, so error messages can showin any place that you wrote the ‘id. !e can write ‘id with tags like "p#, "div# etc. $ereInfolet wrote ‘id with "div# tag. So we can customi%e the error messages with di&erent si%eand color of fonts. So this method is more perfect that alert box method.

    Register.html

    !irst ame#

    Second ame#

    ser ame#

    )mail *ddress#

    Password #

    +onfirm #

    http://www.infolet.org/search/label/JavaScripthttp://4.bp.blogspot.com/-zQRuLfVXLio/UYJbyUo3TUI/AAAAAAAAERI/FrJjTG9Ac1U/s1600/JavaScript+registration+Validation+with+Error+Messages+in+Same+Page.JPGhttp://www.infolet.org/search/label/JavaScript

  • 8/19/2019 form js

    2/3

    function regvalidate(

    2

    if((document.registerationform.fnamet't.value==""33(document.registerationform.snamet't.va

    lue==""

     2  document.get)lement4&d(,une,.inner5T67 = "!irst name or Second name should not be

    em%t&"8  registerationform.fnamet't.focus(8

      return(false8

     9

    if(document.registerationform.unamet't.value==""

      2

      document.get)lement4&d(,une,.inner5T67 = "ser name field should not be em%t&"8  registerationform.unamet't.focus(8

      return(false8 9

    if(document.registerationform.emailt't.value==""

      2

      document.get)lement4&d(,une,.inner5T67 = ")mail id re:uered"8  registerationform.emailt't.focus(8

      return(false8

      9

    if(document.registerationform.%wdt't.value==""

      2  document.get)lement4&d(,une,.inner5T67 = "Please t&%e a %assword"8

      registerationform.%wdt't.focus(8

      return(false8  9

    if((document.registerationform.%wdt't.value ;= (document.registerationform.c%wdt't.value

      2

  • 8/19/2019 form js

    3/3

      document.get)lement4&d(,une,.inner5T67 = "Password 6ust be e:ual"8

      registerationform.%wdt't.value = ""8

      registerationform.c%wdt't.value = ""8  registerationform.%wdt't.focus(8

      return(false8

      9else

      2

      return(true8  9

    9

    If registration is clear, then page ‘welcome.html will open.

    Welcome.html

    infolet

    Sample Outputs: ' See more at(http())www.infolet.org)*+-)+)registration'form'validation'current'page'appear'error'

    message.html/sthash.012+fh3I.dpuf