/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var regex = new RegExp(o.validate); var result = regex.test(value); // result = true / false //tests password : /^[a-z0-9_-]{6,18}$/ RGB hex : /^#?([a-f0-9]{6}|[a-f0-9]{3})$/ Email : /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/ URL : /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ IP : /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ HTML tag :/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/