Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. custom validation in asp.net

custom validation in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netalgorithmsquestion
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sonia Gupta
    wrote on last edited by
    #1

    i was searching for the email validation (validation control).I found the following line for the custom validation. could u please explain the meaning of the following line? \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

    Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

    J S N D 4 Replies Last reply
    0
    • S Sonia Gupta

      i was searching for the email validation (validation control).I found the following line for the custom validation. could u please explain the meaning of the following line? \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

      Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

      J Offline
      J Offline
      jai 123
      wrote on last edited by
      #2

      function validation() if(document.Form1.txtadvmail.value=="") { alert("Please fill the mailid"); document.Form1.txtadvmail.focus(); return false; } if (checkMailId(document.Form1.txtadvmail.value)==false) { document.Form1.txtadvmail.value="" document.Form1.txtadvmail.focus(); return false; } function checkMailId(id) { var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro' ,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al', '.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb', '.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs', '.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci', '.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de', '.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et', '.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh', '.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy', '.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io', '.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki', '.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk', '.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk', '.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw', '.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np', '.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm', '.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa', '.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn', '.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj', '.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug', '.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu', '.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'); var mai = id; var val = true; var dot = mai.lastIndexOf("."); var ext = mai.substring(dot,mai.length); var at = mai.indexOf("@"); var dom = dot - at; var sp = mai.indexOf(" "); if(dom >= 4 && at >1 && sp == -1) { for(var i=0; i<arr.length; i++) { if(ext == arr[i]) { val = true; break; </x-turndown>

      N S 2 Replies Last reply
      0
      • S Sonia Gupta

        i was searching for the email validation (validation control).I found the following line for the custom validation. could u please explain the meaning of the following line? \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

        Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

        S Offline
        S Offline
        sidbaruah
        wrote on last edited by
        #3

        w stands for an alphabet like 'a','b' etc!! \w means it can be any no of alphabets so it confirms that the email id starts with an alphabet then within it ([-+.] means it can have any of these characters in between \w at the end ensures that the email id ends with a alphabet as well then a compulsory @ and so on!!!!

        I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

        S 1 Reply Last reply
        0
        • S Sonia Gupta

          i was searching for the email validation (validation control).I found the following line for the custom validation. could u please explain the meaning of the following line? \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

          Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Are you familiar with regular expressions ?

          Sonia Gupta wrote:

          \w+

          This line matches for any characters, numbers and alphabets

          Sonia Gupta wrote:

          ([-+.]\w+)*@

          This is another regular expression (nested). This matches a single character that is a word charcter and force to match "@".

          Sonia Gupta wrote:

          [-.]

          Matches a single character present in the list. I think from this information you can iterate the remaining. Try for it.


          My Website | Ask smart questions

          S 1 Reply Last reply
          0
          • J jai 123

            function validation() if(document.Form1.txtadvmail.value=="") { alert("Please fill the mailid"); document.Form1.txtadvmail.focus(); return false; } if (checkMailId(document.Form1.txtadvmail.value)==false) { document.Form1.txtadvmail.value="" document.Form1.txtadvmail.focus(); return false; } function checkMailId(id) { var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro' ,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al', '.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb', '.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs', '.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci', '.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de', '.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et', '.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh', '.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy', '.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io', '.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki', '.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk', '.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk', '.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw', '.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np', '.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm', '.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa', '.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn', '.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj', '.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug', '.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu', '.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'); var mai = id; var val = true; var dot = mai.lastIndexOf("."); var ext = mai.substring(dot,mai.length); var at = mai.indexOf("@"); var dom = dot - at; var sp = mai.indexOf(" "); if(dom >= 4 && at >1 && sp == -1) { for(var i=0; i<arr.length; i++) { if(ext == arr[i]) { val = true; break; </x-turndown>

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            :confused::confused::confused:


            My Website | Ask smart questions

            1 Reply Last reply
            0
            • N N a v a n e e t h

              Are you familiar with regular expressions ?

              Sonia Gupta wrote:

              \w+

              This line matches for any characters, numbers and alphabets

              Sonia Gupta wrote:

              ([-+.]\w+)*@

              This is another regular expression (nested). This matches a single character that is a word charcter and force to match "@".

              Sonia Gupta wrote:

              [-.]

              Matches a single character present in the list. I think from this information you can iterate the remaining. Try for it.


              My Website | Ask smart questions

              S Offline
              S Offline
              Sonia Gupta
              wrote on last edited by
              #6

              OK thanks Navaneeth......:)

              Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

              1 Reply Last reply
              0
              • S sidbaruah

                w stands for an alphabet like 'a','b' etc!! \w means it can be any no of alphabets so it confirms that the email id starts with an alphabet then within it ([-+.] means it can have any of these characters in between \w at the end ensures that the email id ends with a alphabet as well then a compulsory @ and so on!!!!

                I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

                S Offline
                S Offline
                Sonia Gupta
                wrote on last edited by
                #7

                thanks sid.....:)

                Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                S 1 Reply Last reply
                0
                • S Sonia Gupta

                  thanks sid.....:)

                  Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                  S Offline
                  S Offline
                  sidbaruah
                  wrote on last edited by
                  #8

                  Anytime!!! :)

                  I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

                  1 Reply Last reply
                  0
                  • J jai 123

                    function validation() if(document.Form1.txtadvmail.value=="") { alert("Please fill the mailid"); document.Form1.txtadvmail.focus(); return false; } if (checkMailId(document.Form1.txtadvmail.value)==false) { document.Form1.txtadvmail.value="" document.Form1.txtadvmail.focus(); return false; } function checkMailId(id) { var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro' ,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al', '.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb', '.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs', '.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci', '.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de', '.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et', '.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh', '.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy', '.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io', '.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki', '.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk', '.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk', '.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw', '.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np', '.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm', '.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa', '.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn', '.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj', '.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug', '.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu', '.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'); var mai = id; var val = true; var dot = mai.lastIndexOf("."); var ext = mai.substring(dot,mai.length); var at = mai.indexOf("@"); var dom = dot - at; var sp = mai.indexOf(" "); if(dom >= 4 && at >1 && sp == -1) { for(var i=0; i<arr.length; i++) { if(ext == arr[i]) { val = true; break; </x-turndown>

                    S Offline
                    S Offline
                    sidbaruah
                    wrote on last edited by
                    #9

                    wat exactly does it do??? dint get anything!!!:confused:

                    I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

                    1 Reply Last reply
                    0
                    • S Sonia Gupta

                      i was searching for the email validation (validation control).I found the following line for the custom validation. could u please explain the meaning of the following line? \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

                      Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                      D Offline
                      D Offline
                      dekart_roo
                      wrote on last edited by
                      #10

                      That's a regular expression. It's a syntax for describing patterns within strings, and can be quite powerful. It takes some time and research to understand them, but I find it well worth it. That particular one is a bit strange though... I'm not sure if I fully get what it's going for. I'd suggest something along the lines of: ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups