Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions javascript regex validation alphanumeric
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
javascript regex validation alphanumeric
2 Answer(s)      2 years and 4 months ago
Posted in : JavaScript Questions


How to write javascript regex validation for alphanumeric?


Advertisement
View Answers

May 11, 2012 at 10:49 AM


<html>
<head>
<title> alphanumeric validation using regex</title>
<script type="text/javascript">
    function validate() {
        var name = document.getElementById("name").value;
        var pattern = /^[A-Za-z0-9 ]{3,20}$/;
        if (pattern.test(name)) {
            alert(name +" has alphanumeric value");
            return true;
        } else {
            alert("Name is not valid.Please input alphanumeric value!");
            return false;
        }
    }
</script>

</head>
<body>
<h2>Validating Alphanumeric value of textBox..</h2>
Email Id :
<input type="text" name="name" id="name" />
<input type="submit" value="Check" onclick="validate();"/>
</body>
</html>


May 12, 2012 at 1:13 PM


Alphanumeric contains alphabets(A-Z,a-z) and numbers (0-9).So for validation of alphanumeric you have to check the pattern of combination of these two. Sometimes space is also included in it.

In pattern /^[A-Za-z0-9 ]$/

/../(forward slashes) is used to quote your regular expression.

^ shows beginning of string.

[..] any letter enclosed with in.

$ is used for ending the string.
test() method takes one argument and check that to the pattern.



Related Tutorials/Questions & Answers:
javascript regex validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <title> alphanumeric validation using regex</title> <script type="text
Alphanumeric Validation in JavaScript
Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have.... Alphanumeric validation means a field in the form can accept only numbers
Advertisements
javascript regex validation email
javascript regex validation email  How to write JavaScript regex validation for email?   <html> <head> <title>Email validation using regex</title> <script type="text/javascript">
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
JavaScript regex validate Telephone no.
JavaScript regex validate Telephone no.  JavaScript regex validate Telephone no.    <html> <head> <title>Phone number validation using regex</title> <script type="text/javascript">
javascript regex validate url
javascript regex validate url  How to validate URL in regex Javascript   <html> <head> <title>Url validation using regex</title> <script type="text/javascript"> function validate
JavaScript regex validate Mobile no.
JavaScript regex validate Mobile no.  JavaScript regex validate Mobile no.   <html> <head> <title>Mobile number validation using regex</title> <script type="text/javascript"> function
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate Character.   <html> <head> <title>Character validation using regex</title> <script type="text/javascript"> function
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate Character   <html> <head> <title>Character validation using regex</title> <script type="text/javascript"> function
javascript regex validate currency
javascript regex validate currency  How to validate currency in JavaScript?   <html> <head> <title>Currency validation using regex</title> <script type="text/javascript"> function
JavaScript regex validate validate Zip.
JavaScript regex validate validate Zip.  JavaScript regex validate - how to validate Zip?   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
javascript regex validate Special character
javascript regex validate Special character   javascript regex validate Special character   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
RegEx
RegEx  I want to know the javascript RegEx code for validation of ( ) parenthesis.. The code is validating the parenthesis but after submit the parenthesis is disappear. what should i do
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
JavaScript regex exec() method for text match.
JavaScript regex exec() method for text match.  JavaScript regex exec() method for text match.   <html> <head> <title> regex exec() for text matching</title> <script type="text/javascript">
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions. <html> <script src="combovalidate1.js" type="text/javascript
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
javascript validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...;<INPUT id=register type=button value=Submit name=Submit onclick='javascript
javascript for websites url validation
javascript for websites url validation  javascript for websites url validation   JavaScript Code for URL Validation **function isvalidurl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-.]+.[a-z]{2,4}\/?([^\s<
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
simple javascript validation for numbers
simple javascript validation for numbers  simple javascript validation for register number   Here is a html code that accepts number from...; <title>Mobile number validation using regex</title> <script
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">... file my validation works correctly but when my validation fails i am getting
Javascript validation - Java Beginners
Javascript validation  Hi I have developed the following function for the validation of Zip code,the problem is, when user enters the valid zip code in first attempt, the background color of text box changes to green while I
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
Form Validation with JavaScript
Form Validation with JavaScript  I created a simple form including nine or ten fields in HTML, and i want to validate it in JavaScript. How can i do it? Thanks!!   Hi Friend, Try the following code: 1)register.html
Javascript validation - Java Beginners
Javascript validation  Hi, this is ragav and my doubt is: I am having a input type="file" text box in which the user can browse the required... or not in javascript? plz urgent..   Hi Friend, Try the following code
Advertisements
 

 

 

DMCA.com