/    Sign up×
Community /Pin to ProfileBookmark

Need help for javascript code for below requirement

  • 1. PA is hard coded

  • 2. open field for customer to manually enter the sterilization no

  • 3. The last 2 digit are with ( ) with spacing from number before

  • 4. If the customer enter PA-1234 (56) then Output is PA-1234 (56)

  • 5. if the customer enter PA-1234(56) the Output is PA-1234 (56)

  • 6. if the customer enter PA-123456 the Output is PA-1234 (56)

  • 7. if the customer enter 123456 the Output is PA-1234 (56)

  • 8. if the customer enter 1234 56 the Output is PA-1234 (56)

  • 9. if the customer enter 1234(56) the Output is PA-1234 (56)
  • to post a comment
    JavaScript

    3 Comments(s)

    Copy linkTweet thisAlerts:
    @NachfolgerJun 18.2020 — I'm not sure what you're asking for here, but the job of the forum members is NOT to write code for you.
    Copy linkTweet thisAlerts:
    @NogDogJun 18.2020 — Do some searching on regular expressions (a.k.a. regexes).
    Copy linkTweet thisAlerts:
    @daveyerwinJun 18.2020 — <form>

    PA - <input maxlength=4 name=first> ( <input maxlength=2 name=second> )

    <button>Submit</button>

    </form>

    <script>

    document.forms[0].onsubmit=function(e){

    e.preventDefault();

    sterNo = "PA - " + e.target.first.value + "(" + e.target.second.value + ")"

    alert(sterNo);

    }

    </script>
    ×

    Success!

    Help @mik2016 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.23,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...