HELP - Javascript - Lower Upper Case Needed


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: HELP - Javascript - Lower Upper Case Needed

  1. #1
    Join Date
    May 2005
    Posts
    1

    Question HELP - Javascript - Lower Upper Case Needed

    pls help me ... i cant even solve this problem 2 days already .... me is too bad

    CALL FUNCTION OF JAVA

    function alphaNum(myfield, e, dec)
    {
    var key;
    var keychar;

    if (window.event)
    key = window.event.keyCode;
    else if (e)
    key = e.which;
    else
    return true;
    keychar = String.fromCharCode(key);

    // control keys
    if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
    return true;

    // numbers
    else if ((("0123456789").indexOf(keychar) > -1))
    return true;
    // alphabets
    else if ((("ABCDEFGHIJKLMNOPQRSTUVWSYZ-#").indexOf(keychar) > -1)) ( **** HERE **** )
    return true;

    // decimal point jump
    else if (dec && (keychar == "."))
    {
    myfield.form.elements[dec].focus();
    return false;
    }
    else
    return false;
    }



    JSP

    <td width="124" align="right"><FONT class="fonttype"><b>Job Plan:</b></FONT></td>
    <td width="5"><font class="astfont">*</font></td>

    <td width="120" height="19"><html:text name="myJobPlanPP_JobPlanForm" property="jp_id" size="10" maxlength="10" onkeypress="return alphaNum(this, event)"/></td>

    <td height="2" colspan="10"><html:text name="myJobPlanPP_JobPlanForm" property="jp_desc" size="50" maxlength="50"/>&nbsp;


    QUESTION:
    Italic is the part that need to be changed ..
    A) How to change input value from whatevercase to UPPERCASE n store into DB ? (Do it in JAVASCRIPT)

    SYSTEM REQUIREMENT:
    a. User key in input in "text field" (front-end).
    b. press 'Submit'
    c. javascript will do validation for Input. (my question)
    d. Input successfully stored.

    EXPLANATION:
    - user can key in upper n lower case in "text field".
    - system will change input into UPPERCASE format.
    - only UPPERCASE can support the DB.

    thanks alot

  2. #2
    Join Date
    Jan 2005
    Location
    Reisterstowwn, MD
    Posts
    72
    Not to be a explotive deleted. But you do realize that JavaScript has nothing to do with Java minus their similar syntax, right?

    Anyways, getting passed that, I take it JavaScript doesn't have a toUppserCase method?

    Eh, free bump to you.
    Java has 99 problems but a pointer ain't one

  3. #3
    Join Date
    Aug 2003
    Posts
    313
    The string object should have a toUpperCase method. What you should do is intercept the submit function in your form object and call toUpperCase on the field that you want to change, something like:
    Code:
    <script language="JavaScript">
    function mkFormUpperCase() {
      field.value = field.value.toUpperCase();
    }
    </script>
    
    <form ... onsubmit="mkFormUpperCase(); this.submit();">
      <input type="text" name="field" />
      <input type="submit" />
    </form>
    Should be something similar to that, although my JavaScript is pretty rusty. There should be some decent pages about it. (http://javascript.internet.com/forms/val-cookie.html is ok, not exactly what you are looking for, but it should help.)
    ~evlich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center