How to set an alert when input is not numeric

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Walker

    How to set an alert when input is not numeric

    I have a simple form I created to calculate gross pay after input of pay rate and hours worked minus deductions. I need some sort of function to alert when non-numerical is input in both of these fields, which is the snippet of code below. I am very new to this and so far I am happy with my results, just trying to dummy proof my form.
    Thank You!

    Code:
    <font face="arial, helvetica" size=4>Please enter both the Hourly Rate of Pay (Pay Rate) and Total Hours Worked (Hours) in positive numbers
    </P>
    <br>
    <center>
    <form name=paycheck>
    <table border=9 cellpadding=3 cellspacing=2 width=15%>
    <tr>
    <td colspan=1   </td>
    <td bgcolor="#c0c0c0" align=right><b>Pay Rate:</b></td>
    <td><input type=text name=Hr_Rate  size=5 ;"></td>
    <tr/>
    <tr>
    <td colspan=1  </td>
    <td bgcolor="#c0c0c0" align=right><b>Hours:</b></td>
    <td><input type=text name=Hr_Worked  size=5 ;"></td>
    </tr>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    try to read the value by the isNaN() function, if it’s not a number it returns true.

    Comment

    Working...