Hi there is there possible to validate the input tag with url type?
I currently have an input tag with URL type for user to key in the url, it is okay if the user key in value that is not a url.
But when user key in "http://www.", my input field accept it and posted the form to the server which is not a proper value. How to check the empty value in the input field to validate empty url?
Here are few scenario my form accepted the url link with empty url:
- http://www.
- www.
- http://
Is there any way to validate and stop the form to submit when there are empty value in the url link with javascript or php? thanks
My FORM's CODE:
<form class="form" id="form" action="" method="POST" enctype="multipart/form-data">
<div class="box-body">
<input type="hidden" name="banner_id" value="1"></input>
<div class="form-group" >
<label for="bannerName">Banner Name 旗帜名称</label>
<input type="text" class="form-control" name="bannerName" id="bannerName" placeholder="Please Enter Name" onChange="checkDisabled(testing);">
</div>
<div class="form-group" >
<label for="bannerUrl">Banner URL </label>
<input type="url" autocomplete="on" class="form-control" name="bannerUrl" id="bannerUrl" placeholder="Please Enter Url" onChange="checkDisabled(testing);" required>
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="uploaded_file" name="uploaded_file" onChange="checkDisabled(testing);"><br>
<p class="help-block">Your picture size not more than 2MB. (Only JPEG or JPG is allowed)</p>
</div>
<div class="checkbox">
<button id="testing" type="submit" class="btn btn-primary" disabled>Update</button>
</div>
</div><!-- /.box-body -->
</form> <!-- Date range -->