Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Form Validation

  • 10-03-2008 11:20am
    #1
    Registered Users, Registered Users 2 Posts: 224 ✭✭


    Hi,

    I have a form validation and need to change it. Basically the validation checks a code entered by the user. There are 3 parts to the code, first part 3 alphanumerics, 2 part a year e.g. 2008, 3 part 3 numbers.

    aaa/YYYY/nnn
    e.g. ab1/2008/123

    function validateItemID(input){
    var validformat=/^[a-zA-Z0-9]{3}\/[0-9]{4}\/[0-9]*$/
    if (!validformat.test(input.value)){
    alert("Invalid Item ID format. Must be formatted \"aaa/YYYY/nnn\"")
    return false }
    else {
    return true
    }
    }
    I need to change the code so it will allow any amount of alphanumerics in the first part of the entered code.
    Any help would be appreciated


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    My regex isn't great, but I think this'd work...
    var validformat=/^[a-zA-Z0-9]{3}\/[0-9]{4}\/[0-9]*$/
    Change that 3 to 0,15 ... which I think should allow anywhere between 0 and 15 alphanums for the first part... but make sure to test it out fully.

    I've got this page bookmarked for when I have to deal with regular expressions.


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    savage stuff. that did the trick. Many thanks


Advertisement