Skip to content

Instantly share code, notes, and snippets.

@fatihgune
Created July 26, 2017 21:57
Show Gist options
  • Save fatihgune/90d91dd941bcdd3a4fb2fcd855d82ce1 to your computer and use it in GitHub Desktop.
Save fatihgune/90d91dd941bcdd3a4fb2fcd855d82ce1 to your computer and use it in GitHub Desktop.
Validation regex for turkish plate system.
<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
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