Created
July 26, 2017 21:57
-
-
Save fatihgune/90d91dd941bcdd3a4fb2fcd855d82ce1 to your computer and use it in GitHub Desktop.
Validation regex for turkish plate system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form-group"> | |
<label class="col-md-4 control-label" for="plate">Plate</label> | |
<div class="col-md-4"> | |
<input pattern="/^(0[1-9]|[1-7][0-9]|8[01])(([A-PR-VYZ])(\d{4,5})|([A-PR-VYZ]{2})(\d{3,4})|([A-PR-VYZ]{3})(\d{2,3}))$/" | |
minlength="7" maxlength="8" id="plate" name="plate" type="text" placeholder="ex:35GS1905" class="form-control" required> | |
</div> | |
</div |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validate; | |
validate = function(val) { | |
var regex, v; | |
v = val.replace(/\s+/g, '').toUpperCase(); | |
regex = /^(0[1-9]|[1-7][0-9]|8[01])(([A-PR-VYZ])(\d{4,5})|([A-PR-VYZ]{2})(\d{3,4})|([A-PR-VYZ]{3})(\d{2,3}))$/ | |
return v.match(regex) != null; | |
}; | |
//Harfler inputta büyük harfe çevrilip aralarındaki boşlukar silinecektir. XWQ ve türkçe karakterleri kabul etmeyecktir. | |
/* Uyuşacağı paternler | |
//R: Rakam | |
//H: Harf | |
RRHRRRR - RRHRRRR - RRHHRRR - RRHHRRRR - RRHHHRR -RRHHHRRR | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment