Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Javascript Validate email address


function validateEmail(email) {
    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(String(email).toLowerCase());
}

/* 
Javascript
Validate phone number
*/

function validatePhone(phone) {
    var re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;
    return re.test(String(phone).toLowerCase());
}

/* 
Javascript
Validate password
*/

function validatePassword(password) {
    var re = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
    return re.test(String(password).toLowerCase());
}

/* 
Javascript
Validate name
*/

function validateName(name) {
    var re = /^[a-zA-Z ]{2,30}$/;
    return re.test(String(name).toLowerCase());
}

/* 
Javascript
Validate address
*/

function validateAddress(address) {
    var re = /^[a-zA-Z0-9\s,'-]*$/;
    return re.test(String(address).toLowerCase());
}

/* 
Javascript
Validate city
*/

function validateCity(city) {
    var re = /^[a-zA-Z]+(?:[\s-][a-zA-Z]+)*$/;
    return re.test(String(city).toLowerCase());
}

/* 
Javascript
Validate state
*/

function validateState(state) {
    var re = /^[a-zA-Z]+(?:[\s-][a-zA-Z]+)*$/;
    return re.test(String(state).toLowerCase());
}

/* 
Javascript
Validate zip code
*/

function validateZip(zip) {
    var re = /^\d{5}(?:[-\s]\d{4})?$/;
    return re.test(String(zip).toLowerCase());
}

/* 
Javascript
Validate credit card
*/

function validateCreditCard(creditCard) {
    var re = /^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/;
    return re.test(String(creditCard).toLowerCase());
}

/* 
Javascript
Validate cvv
*/

function validateCvv(cvv) {
    var re = /^[0-9]{3,4}$/;
    return re.test(String(cvv).toLowerCase());
}

/* 
Javascript
Validate expiration date
*/

function validateExpDate(expDate) {
    var re = /^(0[1-9]|1[0-2])\/?([0-9]{4}|[0-9]{2})$/;
    return re.test(String(expDate).toLowerCase());
}

/* 
Javascript
Validate quantity
*/

function validateQuantity(quantity) {
    var re = /^[0-9]{1,2}$/;
    return re.test(String(quantity).toLowerCase());
}

/* 
Javascript
Validate price
*/

function validatePrice(price) {
    var re = /^\d+(?:\.\d{0,2})$/;
    return re.test(String(price).toLowerCase());
}

/* 
Javascript
Validate description
*/

function validateDescription(description) {
    var re = /^[a-zA-Z0-9\s,'-]*$/;
    return re.test(String(description).toLowerCase());
}

/* 
Javascript
Validate image
*/

function validateImage(image) {
    var re = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
    return re.test(String(image).toLowerCase());
}

/* 
Javascript
Validate category
*/

function validateCategory(category) {
    var re = /^[a-zA-Z]+(?:[\s-][a-zA-Z]+)*$/;
    return re.test(String(category).toLowerCase());
}

/* 
Javascript
Validate subcategory
*/

function validateSubcategory(subcategory) {
    var re = /^[a-zA-Z]+(?:[\s-][a-zA-Z]+)*$/;
    return re.test(String(subcategory).toLowerCase());
}

/* 
Javascript
Validate product name
*/

function validateProductName(productName) {
    var re = /^[a-zA-Z0-9\s,'-]*$/;
    return re.test(String(productName).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;
    return re.test(String(productId).toLowerCase());
}

/* 
Javascript
Validate product id
*/

function validateProductId(productId) {
    var re = /^[0-9]{1,10}$/;

Enter fullscreen mode Exit fullscreen mode

Latest comments (0)