SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    India
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validation of amount

    i have used following javascriot code for entering the numeric data.

    but it does not accept values likes 1 2 3 4....


    Cheque Amount:
    <input type="text" name="chqamt" size="12" maxlength="12"onblur=" var x = parseFloat(this.value);if(!this.value.match(/[\d]+\.?[\d+]/)) { alert('Enter valid amount'); this.value = '';} else if( !(x%1) ) { this.value = x + '.00';}">

    my second problem is that i have two text field as follow: and i have used following validation for the same.

    Below mentioned text field has taken values from some other text field and add them..its working..i want to do that after taken values from respective text field,if the values of both the text field is not equals..it shows alert message...and clear the values..

    <td> <input type="text" name="tdebit" size="12" onclick="
    var odebit = parseFloat(this.form.debit.value);
    var odebit1 = parseFloat(this.form.debit1.value);
    this.value = odebit+odebit1 ;" readonly></td>

    <td> <input type="text" name="tcredit" size="12" onclick="
    var ocredit2 = parseFloat(this.form.credit.value);
    var ocredit21 = parseFloat(this.form.credit1.value);
    this.value = ocredit2+ocredit21;" readonly></td>

  2. #2
    SitePoint Addict
    Join Date
    May 2004
    Location
    Europe
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe this:
    Code:
    <input onblur="var x=parseFloat(this.value);if (isFinite(x)) this.value=x.toFixed(2); else { alert('Enter valid amount'); this.value = '';}">
    Sorry, I don't think I understand your second problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •