Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

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
 
You showed up just in time for the waffles! And this 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