function validateEmail(email) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/;
return emailReg.test(email);
}
Usage:-
if(validateEmail(emailString)){
alert('Your email is valid');
}
else{
alert('Your email is not valid! There should be atleast @ and one dot(.) present in it');
}
First add the custom method to the validation library as below. Can you put this code in your jquery validation file or in your page where you want to validate the date, just before setting your validation rule for your form.
$.validator.addMethod(“dateFormat”,
function (value, element) {
return value.match(/^(?:(0[1-9]|1[012])[\/.](0[1-9]|[12][0-9]|3[01])[\/.](19|20)[0-9]{2})$/);
},“Please enter a date in the format mm/dd/yyyy.”);
Now suppose you are using a datepicker or input field to accept the date in mm/dd/yyyy format like 02/21/2018 as example. You can validate it as below;
<script type="text/javascript">
function isValideDate(datavalue){
var regexValidDate = /^(?:(0[1-9]|1[012])[\/.](0[1-9]|[12][0-9]|3[01])[\/.](19|20)[0-9]{2})$/;
return regexValidDate.test(datavalue);
}
var dateToCheck = '06/01/2011',
if(isValideDate(dateToCheck)){
alert("Given date is valid as per the format of MM/dd/YYYY");
}else{
alert("Given date is not valid as per the format of MM/dd/YYYY");
}
</script>
<html>
<body>
<h1>Welcome to my Website</h1>
<h4 id=”msg”>You will be redirected to another page in 5 seconds!</h4>
<script type=”text/javascript”>
function countDown(i, callback) {
callback = callback || function(){};
var int = setInterval(function() {
//document.getElementById(“displayDiv”).innerHTML = “Number: ” + i;
document.getElementById(“msg”).innerHTML = “You will be redirected to backend page in “+i+” seconds!”;
i– || (clearInterval(int), callback());
}, 1000);
}
setTimeout(function(){
countDown(5, function(){
window.location=”[Give your absolute or relative url to redirect]”;
});
}, 3000);
</script>
</body>
</html>
The below command will create a tar archive file whatevername_yougive.tar for a directory /path/of/directory/to/archive in current working directory.
See the example below.
tar cvf whatevername_yougive.tar /path/of/directory/to/archive
The options detail are explained as below
c – Creates a new .tar archive file.
v – Verbosely show the .tar file progress.
f – File name type of the archive file.
Similarly to create tar.gz file
tar cvzf whatevername_yougive.tar.gz /path/of/directory/to/archive
In your controller file add the following code to set the public property to the uploaded image.
if (request()->hasFile(‘image_field_name_inyour_form’)) {
$folderPath = ‘profile/thumbnailfolder/’; // Set the folder path where you want to upload on s3 bucket
$imageName = time().rand(0,999999).’.’.request()->file(‘main_image’)->getClientOriginalExtension(); // Set name for the uploaded image with extension
$imageObj = request()->file(‘main_image’); // This will retrieve the uploaded images attributes. in short the file objects.
$uploadResponse = Storage::disk(‘s3’)->put($folderPath.$imageName, file_get_contents($imageObj), ‘public’); // here if you dont set the “public” attributes, when you access the file in your browser it will display access permission denied error.
$imageNameToStoreInYourDbOrCode = $imageName;
}
Hope you like the code. Please write back for any queries.
The column which you want to wrap should be added the property called “contentOptions” where you can apply the css property to suits your needs and requirements as below.