• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

alphanumeric range Validation

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am trying to run a simple html page with a java script validation for range validation

i have two text fields in which user enters two alphanumeric values
i have to validate if the first value is less than second or not.
when i click on submit i am getting "document.id.value" is null or not an
object

my function is



how to fix this...
thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.FormName.ElementName.value

plus

...value > ...value is comparing strings you need to use parseFloat if it is numbers.

Eric
 
raj kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
i have changed to use the form name and field names...

but the values of ids i have is alphanumeric, so i have to compare for the string part of it and then the integer part of it.

like if i have from "bc1" to "cd4" then i have to first compare if b<c which is true and also if they are "bc1" and "bc2" then also its true as here 1<2 but if they are like "bc1" and "ac2" then it is false as b>a ...
hope i am clear?

thanks,
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raj,

Looks like you need to write your own comparison routine to validate this since this is a pretty unique case.
what is the logic for the following cases
12BAR & BAR12
or AB124 & ABC12
& what if they have strings of varying lengths ??

First u need to validate if they are valid alpha-numeric characters ( a simple search wud give you free examples) & then get one character from each & continue your check using

HTH
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic