SitePoint Sponsor

User Tag List

Page 2 of 5 FirstFirst 12345 LastLast
Results 26 to 50 of 120
  1. #26
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where can u modify it please..

  2. #27
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    where can u modify it please..
    You can modify it by placing the digits in to the same class as the characters.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am not getting you

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    i am not getting you
    Here's some documentation on what a character class is.
    Character Class or Character Sets
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    means i need to give [a-z0-9._-]
    so that it should match only these characters.
    in username

  6. #31
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have absolutely no idea on regular expressions.
    please can u modify that for me ........

  7. #32
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    I have absolutely no idea on regular expressions.
    please can u modify that for me ........
    Before you had [a-z][0-9]

    Putting them both in the same character class means to do this:
    [a-z0-9]
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #33
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whether it will work.below is the given code
    and my username should also work with .(dot),_(underscore),-(hypen)

    function checkName(form) /* for real name verification */
    {
    var re =[a-z0-9];
    var isCorrectFormat = re.test(form);
    if (!isCorrectFormat)
    {
    alert("Invalid characters in username. It can only contain...");
    return false;
    }

  9. #34
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    ar re =[a-z0-9];
    Let me try to explain this again, in simpler terms that you might find easier to understand.

    Before you had this non-working code:

    Code javascript:
    var re =/^[a-z][0-9]{4}[._-]\d{3}/i;

    Where you have [a-z][a-9] you should instead have [a-z0-9]

    Does that make sense to you?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #35
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you think like below written one...
    do u think this will work

    function checkName(form) /* for real name verification */
    {
    var re =/^[a-z0-9]{4}[._-]\d{3}/i;
    var isCorrectFormat = re.test(form);
    if (!isCorrectFormat)
    {
    alert("Invalid characters in username. It can only contain...");
    return false;
    }

  11. #36
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    do you think like below written one...
    do u think this will work
    What does testing it reveal to you?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #37
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for anything we give username a valid also id is displaying error say
    usernae is ravi for this also it is displaying error.

  13. #38
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    for anything we give username a valid also id is displaying error say
    usernae is ravi for this also it is displaying error.
    Something must be wrong with my linguistic interpreter, because "username a valid also id" doesn't seem to parse in to anything vaguely understandable.

    Can you please repeat in a way that can be understood, and perhaps let us know what you are actually testing?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #39
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i am working on a simple registration form that has 5 fields as username,email id,password,retype password and phone number.
    where username should be atleast 4 characters long including special characters like .(dot),_(underscore),-(hypen).
    email id should be of valid one
    and password and retype password should match
    phone no should be of 10 digits ..

    here is my complete code
    i find a problem in testing for username and password field.if i enter password field of length less than 6 characters it should display alert message i have written as the length should be atleast 6 characters but it is asking to enter for retype password field and then displaying the message "it should be of length 6 characters"(given password is less than 6 characters)
    can u check it once where i have gone wrong.

    <html>
    <head>
    <meta charset="utf-8">
    <title>Validation using JavaScript</title>
    <script type="text/javascript">
    function checkName(form) /* for real name verification */
    {
    var re =/^[a-z0-9]{4}[._-]\d{3}/i;
    var isCorrectFormat = re.test(form);
    if (!isCorrectFormat)
    {
    alert("Invalid characters in username. It can only contain._ and-");
    return false;
    }


    if (form.realname.value == '')
    {
    alert('Error: Username cannot be blank!');
    form.realname.focus();
    return false;
    }
    else if(form.realname.value.length < 4)
    {
    alert("UserName should be atleast 4 characters long");
    return false;
    }


    return true;
    }

    function checkEmail(form) /* for email validation */
    {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value))
    {
    return true;
    }

    alert('Invalid E-mail Address! Please re-enter.');
    return false;
    }

    function validatePwd(form) /* password & retype-password verification */
    {
    var invalid = ' ';
    minLength = 6;
    var pw1 = form.password.value;
    var pw2 = form.password2.value;


    if (pw1 == '' || pw2 == '')
    {
    alert('Please enter your password twice.');
    return false;
    }


    if (form.password.value.length < minLength)
    {
    alert('Your password must be at least ' + minLength + ' characters long. Try again.');
    return false;
    }

    if (document.form.password.value.indexOf(invalid) > -1)
    {
    alert('Sorry, spaces are not allowed.');
    return false;
    }
    else
    {
    if (pw1 != pw2)
    {
    alert('You did not enter the same new password twice. Please re-enter your password.');
    return false;
    }
    else
    {
    alert('Passwords Match.');
    return false;
    }

    return false;
    }
    }

    function validPhone(form) /* phone no validation */
    {
    var valid = '0123456789';
    phone = form.phoneno.value;

    if (phone == '')
    {
    alert('This field is required. Please enter phone number');
    return false;
    }

    if (!phone.length > 1 || phone.length < 10)
    {
    alert('Invalid phone number length! Please try again.');
    return false;
    }

    for (var i = 0; i < phone.length; i++)
    {
    temp = '' + phone.substring(i, i + 1);

    if (valid.indexOf(temp) == -1)
    {
    alert('Invalid characters in your phone. Please try again.');
    return false;
    }
    }

    return true;
    }

    function validate()
    {
    var form = document.forms['form'];

    if (!checkName(form) || !checkEmail(form) || !validatePwd(form) || !validPhone(form))
    {
    return false;
    }

    return true;
    }
    </script>
    </head>
    <body>

    <form action="" method="post" name="form" onsubmit="return validate()">
    User Name : <input type="text" name="realname" size="19">
    <br>
    E-Mail : <input type="text" name="email" size="25">
    <br>
    Password : <input type="password" name="password" maxlength="12" size="25">
    <br>
    Retype password: <input type="password" name="password2" maxlength="12" size="25">
    <br>
    PhoneNo : <input type="phoneno" name="phoneno" maxlength="10" size="25">
    <br>
    <input type="submit" value="Submit">
    </form>

    </body>
    </html>

  15. #40
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    actually i am working on a simple registration form that has 5 fields as username,email id,password,retype password and phone number.
    where username should be atleast 4 characters long including special characters like .(dot),_(underscore),-(hypen).
    email id should be of valid one
    and password and retype password should match
    phone no should be of 10 digits ..
    I'm currently suffering from a head-hammering cold, so you should go back to the code that you got from the other guy.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #41
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k at least tellme whats wrong with the username.why it is not accepting special characters.is there any wrong in regular expression..

  17. #42
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    k at least tellme whats wrong with the username.why it is not accepting special characters.is there any wrong in regular expression..
    You'll need to clarify all of the variations of username that are to be considered valid.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #43
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for username cannot be blank and length of username it is working
    but not for regular expression.

  19. #44
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    for username cannot be blank and length of username it is working
    but not for regular expression.
    What are all of the variations of username that are to be considered valid?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #45
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for a user to be considered as valid it should be more than 4 characters and only 3 special characters .(dot),_(underscore) and -(hypen) are allowed
    some thing like ravi.951 and ravi_951 and ravi-951
    and ravi!951 or ravi951@.... should be invalid

  21. #46
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    for a user to be considered as valid it should be more than 4 characters and only 3 special characters .(dot),_(underscore) and -(hypen) are allowed
    some thing like ravi.951 and ravi_951 and ravi-951
    and ravi!951 or ravi951@.... should be invalid
    Is it always going to be four characters at the start (not three or five), followed by punctuation, then only three numbers at the end?

    Will Teddy.19 be invalid, but Tedd.019 be valid?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #47
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no atleast 4 characters.(maybe 5 or 6 or 7)
    valid examples teddy.123 is valid
    and teddy.123_ravi should be invalid only one special character is allowed(out of .,_,-)
    both Teddy.19 & Tedd.019 are valid

  23. #48
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    no atleast 4 characters.(maybe 5 or 6 or 7)
    Let me know when you decide what you require.

    valid examples teddy.123 is valid
    and teddy.123_ravi should be invalid only one special character is allowed(out of .,_,-)
    both Teddy.19 & Tedd.019 are valid[/QUOTE]

    Will there be numbers allowed before the separator, or will you allow characters with the numbers?
    e.g., t3ddy.12e
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  24. #49
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya both are allowed
    t3ddy.12e is valid.
    just as in gmail and yahoo usernames...

  25. #50
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    ya both are allowed
    t3ddy.12e is valid.
    just as in gmail and yahoo usernames...
    How many characters will you allow after the separator? Current examples show 3, but will you allow that to vary?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •