Jump to content
  • 0

Walidacja numeru telefonu przy zamówieniu


Krystian Kwiatos

Question

10 answers to this question

Recommended Posts

  • 0

w pliku validate.php rozwiązałem to w ten sposób i działa - 

public static function isPhoneNumber($number){
        $stripped = preg_replace('/[^0-9]/', '', $number);
        $len = strlen($stripped);
        $min = 9;
        $max = 11;
        if ($len >= $min && $len <= $max){
          return preg_match('/^[+0-9. ()-]*$/', $number);
        }else{
         return false;
        }
      }

Dziękuję @endriu107 za pomoc :)

Link to comment
Share on other sites

  • 0
let address = document.querySelector("input[name'phone']");
let addressBtn = document.querySelector("button[name'confirm-addresses']");

function ready() {
	if (addressBtn) {
		address.addEventListener('keyup', () => {
			if (address.value.match(".*\\d.*")) {
               addressBtn.removeAttribute('disabled','')
			   addressBtn.setAttribute('enabled','')
			} else {
				addressBtn.removeAttribute('enabled','')
				addressBtn.setAttribute('disabled','')
			}
		})
	}
}

document.addEventListener("DOMContentLoaded", ready);

Napisałem to w ten sposób jednak nie mam pojęcia w jaki sposób sprawdzać czy numer jest poprawny

Link to comment
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
×
×
  • Create New...