I was able to generate URLs by including codes for a catalog I have validated the number of characters and numbers that should be put into the textarea.
I would somehow validate the generated URLs are valid otherwise show something like "url does not work"
JQUERY:
$('#enter').keyup(function () {
var eachLine = $(this).val().split('\n');
var result = '';
for (var i = 0; i < eachLine.length; i++) {
var url = 'http://67.227.171.193/~raulvalv/code/replace/gallery/' + eachLine[i] + '_2.jpg';
var img = '<img alt="" src="' + url + '" /><br />';
var empty = '<div class="found">Error code</div><br />';
if (eachLine[i].match(/^[0-9]{10}$/)) {
result = result + img + '\n';
//
} else {
result = result + empty + '\n';
}
}
$('#hide').show();
$('#result').html(result);
});
$('.reset').on('click', function () {
$('#enter').trigger('keyup');
$('#hide').hide();
});
$('#search').on('click', function () {
$('#enter').trigger('keyup');
});
HTML:
<form>
<h3>Enter:</h3>
<textarea value="" id="enter"></textarea>
<br />
<button id="search" class="btn btn-primary">Search</button>
<div id="hide">
<h3>Result:</h3>
<div id="result"></div>
<br />
<input type="reset" value="Reset" class="button reset" />
</div>
</form>
Sample code to enter in textarea:
9998524561
9991239872
9999517533
9994561234
9994561235
The last code results in a nonexistent URL, should show some message.
Any idea to validate the url and display a message that the url does not exist?
JSFIDDLE: