Jump to content

ahmedarain24

New Members
  • Posts

    6
  • Joined

  • Last visited

Community Answers

  1. ahmedarain24's post in String to Uppercase Problem was marked as the answer   
    Based on the code you provided, it seems that you are trying to convert the value of `newent` to uppercase using the `strtoupper()` function. However, it appears that the uppercase conversion is not working as expected and accepting any character.
    To properly convert the value to uppercase in JavaScript, you should use the `toUpperCase()` method instead of `strtoupper()`. Here's the corrected code:
    ```javascript
    newent.value = newent.value.toUpperCase();
    if (newent.value === 'B' || newent.value === 'P' || newent.value === 'T' || newent.value === 'D') {
        EnterSw.value = 0;
        return true;
    } else {
        alert('INVALID HAND / MAIN INVALID');
        newent.select();
        return false;
    }
    ```
    With this modification, the `toUpperCase()` method will convert the value of `newent` to uppercase, and the subsequent comparisons will check against uppercase characters ('B', 'P', 'T', 'D').
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.