• Post Reply Bookmark Topic Watch Topic
  • New Topic

sample code for validation  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to validate a page where im adding data specific to the copncerned person like name,phonenumber,occation,date .How do i write a validate method which checks that all fields are entered if not it has to displa an alert .Will be really great if anyone can help Thanks in advance .
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You may try doing it this way.


Hope this helps. Cheers.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if(phoneNo.length()==0||name.length()==0){ return true; }else{ return false; }
I think except Validating the field empty
It should Validate whether the user input alphabetic characters in phone field.
 
Oscar Kamau
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You do not need to validate whether the user has entered an alphabet in the phoneNo text field. This is why:

While creating the text field instance, you specify whether the text field will accept numbers, password, alphabets etc. For example,


See this example. You can search for more. Regards
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!