Jump to content
php.lv forumi
Sign in to follow this  
NMY

Regex tēma

Recommended Posts

[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) ?

Share this post


Link to post
Share on other sites

Kaut kā ļoti līdzīgi. Kas vainas tavam regexam, kkādi konkrēti case neiet?

Te var smuki testēt: https://regex101.com/

Share this post


Link to post
Share on other sites
[0-9]{1,6}(\.|,){0,1}[0-9]{0,2}

Ja atstāj tukšu, tad pattern nebļauj un forma sūta empty :(

 

Share this post


Link to post
Share on other sites

Nav taisnība.

Share this post


Link to post
Share on other sites

Tukšs input netiek cauri, jo regex sākas ar [0-9]{1,6}. Vai domā tukšumu aiz komata?

Share this post


Link to post
Share on other sites

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>"...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×