<script>
jQuery.validator.addMethod("linkedinUrl", function(value, element) {
return this.optional(element) || /(ftp|http|https):\/\/?(?:www\.)?linkedin.com(\w+:{0,1}\w*@)?(\S+)(:([0-9])+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(value); }, "Please enter valid linkedin url!" );
$(function () {
$("#Add_Staff_Form").validate({
rules: {
linkedin:"linkedinUrl",
},
ignore: ':hidden:not([class~=selectized]),:hidden > .selectized, .selectize-control .selectize-input input'
});
});
</script>
在html中添加:
<div class="col-md-4">
<label class="control-label">Linkedin</label>
<input type="text" id="linkedin" name="linkedin" class="form-control linkedinUrl" value="" />
</div>