eT` Posted January 3, 2013 Report Share Posted January 3, 2013 Sveiki, Kā Jūs realizētu telefona numura validāciju ievades laukā, ja drīkst būt jebkuras pasaules malas telefona numurs. saglabātu visu valstu telefona numuru uzbūvi un validētu numuru pēc valsts koda vai ir kāds gatavs divritenis? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted January 3, 2013 Report Share Posted January 3, 2013 http://code.google.com/p/libphonenumber/'>Viens vellapēds ir. Quote Link to comment Share on other sites More sharing options...
Kasspars Posted January 3, 2013 Report Share Posted January 3, 2013 Tā uz sitienu šķiet, ka nav vienotas formulas kā validēt telefona numuru. Nu es atļautu tikai ciparus, tukšumu, - un + tipa "+371 238-443-22" vai "+37123844322" Katrā ziņā nebūtu labi baigi ierobežot lietotāju uz telefona numura ievadi Quote Link to comment Share on other sites More sharing options...
aaxc Posted January 3, 2013 Report Share Posted January 3, 2013 Mums ir apmēram šādi izveidots: function regexp_this(r_str, r_type) { if(r_type == 'phone') var rexp = /^(\+|00)([0-9]){3}( |)(2){1}([0-9]){7}( |)$/; else if(r_type == 'postal') var rexp = /^(LV\-)([0-9]){4}$/; else if(r_type == 'pers_code') { // datumi kuros ir 01 liidz 28 datums var datums0128 = "([012][1-8]|[01]9|[12]0)(0\\d|1[012])\\d{2}"; // datumi kuros ir 30 liidz 31 datums var datums3031 = "3(0(0[13-9]|1[012])|1(0[13578]|1[02]))\\d{2}"; // datumi kuros ir 29 datums var datums29 = "29(02([02468][048]|[13579][26])|(0[13-9]|1[012])\\d{2})"; var rexp = new RegExp("^((" + datums0128 + ")|(" + datums3031 + ")|(" + datums29 + "))-[12]\\d{4}$"); } if(rexp) { return rexp.test(r_str); } else return false; } Un pielietojums: if( !regexp_this(document.form2.mobile.value, 'phone') ) { passed = false; }else{ passed = true; } Quote Link to comment Share on other sites More sharing options...
F3llony Posted January 3, 2013 Report Share Posted January 3, 2013 Šāds topiks šeit jau ir bijis. Izmanto meklēšanas funkciju. Quote Link to comment Share on other sites More sharing options...
Kavacky Posted January 3, 2013 Report Share Posted January 3, 2013 aaxc variants ārpus Latvijas konkrēti nestrādā un kaut cik strādā varbūt tikai mobilajiem. Quote Link to comment Share on other sites More sharing options...
aaxc Posted January 3, 2013 Report Share Posted January 3, 2013 Jā, tas ir uz LV mobilajiem domāts. Quote Link to comment Share on other sites More sharing options...
marcis Posted January 3, 2013 Report Share Posted January 3, 2013 Visai interesantas regulārās izteiksmes :) sarkasms, ja kas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.