jqBootstrapValidation icon indicating copy to clipboard operation
jqBootstrapValidation copied to clipboard

url validators

Open maksimize opened this issue 12 years ago • 2 comments

i can't find validation for url i knew it can be done using regex validation but i think it should have the url rule

maksimize avatar Dec 20 '12 11:12 maksimize

Good idea. I'm working on the documentation currently so I can't add it right now, but I'll mark it as an enhancement request for later.

Did you find a suitable regex? if not, this one was recommended on stackoverflow:

(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}

and this one on nettuts:

(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?

but I haven't had chance to test them out.

ReactiveRaven avatar Dec 23 '12 07:12 ReactiveRaven

I also think that's a great idea. Here is the code I used in the meantime.

<div class="form-group control-group">
    <label for="website">Website</label>
    <input type="url" class="form-control" id="website" name="website"
           data-validation-regex-regex="(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}" 
           data-validation-regex-message="Please enter a valid URL" />
    <p class="help-block"></p>
</div>

natezander avatar Feb 04 '14 18:02 natezander