NMY Posted March 8, 2018 Report Share Posted March 8, 2018 Gribēju izveidot tēmu, kurā jautāt palīdzību par Regulāro izteiksmi Quote Link to comment Share on other sites More sharing options...
NMY Posted March 8, 2018 Author Report Share Posted March 8, 2018 [0-9]{1,6}(\.|,){0,1}[0-9]{0,2} Netieku gudrs, kā HTML formā pattern uzrakstīt tā, lai var ievadīt skaitļus (ar punktu vai komatu) un lai šis lauks (nebūtu <empty>, nebūtu burti) ? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 8, 2018 Report Share Posted March 8, 2018 Kaut kā ļoti līdzīgi. Kas vainas tavam regexam, kkādi konkrēti case neiet? Te var smuki testēt: https://regex101.com/ Quote Link to comment Share on other sites More sharing options...
NMY Posted March 8, 2018 Author Report Share Posted March 8, 2018 [0-9]{1,6}(\.|,){0,1}[0-9]{0,2} Ja atstāj tukšu, tad pattern nebļauj un forma sūta empty :( Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 8, 2018 Report Share Posted March 8, 2018 Nav taisnība. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 8, 2018 Report Share Posted March 8, 2018 Tukšs input netiek cauri, jo regex sākas ar [0-9]{1,6}. Vai domā tukšumu aiz komata? Quote Link to comment Share on other sites More sharing options...
NMY Posted March 9, 2018 Author Report Share Posted March 9, 2018 Man sanāca tā: ievadu "a" burtu un HTML pattern bļauj, izdzēšu "a" burtu un submit nostrādā. Aizsūtās laikam "<nil>"... Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 9, 2018 Report Share Posted March 9, 2018 Ahā! https://stackoverflow.com/questions/20926753/pattern-attribute-on-input-element-allows-empty-values https://jsfiddle.net/u46mjar7/2/ Quote Link to comment Share on other sites More sharing options...
NMY Posted March 9, 2018 Author Report Share Posted March 9, 2018 daGrevis paldies! 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.