Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Anyone can help me?

I had create a function in html for disable text field if the user input is same with word I set in the function. Then if all the text field are disable, so the prompt will appear.

My question : how I want to check whether all my text field had disable?

Anyone know what to do? What I need to add in the code?

<script language="JavaScript">
   
    function setText(){
	
      if(document.check.huruf4.value == "ا")
	  {
		document.check.huruf4.disabled = true;  
	  }
	  if(document.check.huruf3.value == "ل")
	  {
		document.check.huruf3.disabled = true;  
	  }
	  if(document.check.huruf2.value == "و")
	  {
		document.check.huruf2.disabled = true;  
	  }
	  if(document.check.huruf1.value == "ب")
	  {
		document.check.huruf1.disabled = true;  
	  }
	 } 
Posted
Updated 26-Mar-11 9:21am
v2

1 solution

At the end of the entry, when you need to know if all the fields are disable or not, call a Javascipr method.
In this methid, check for all your 4 textbox disable status. If you find any one not disabled send a false flag as return. If you have all disabled, show/do your stuff there.

Try!
 
Share this answer
 
Comments
LearningPerson 27-Mar-11 2:48am    
i know that...but i don't how write it... can u please show me the way...
Sandeep Mewara 27-Mar-11 3:29am    
For 2 controls:
if(!document.check.huruf1.disabled)
{
// 1 is still enabled
return false;
}
else if(!document.check.huruf2.disabled)
{
// 2 is still enabled
return false;
}
..
..
..

Try yourself now.
LearningPerson 27-Mar-11 12:11pm    
thank for the code...i will try this one...
LearningPerson 27-Mar-11 12:32pm    
thank a lot for ur help...my code is running according to what i want..
can i have ur favor one more time...

when the answer is correct...i had done an alert on it and it running...but if one of the disable are false i want to come out with an alert...i try to write the but it seem not working if one of the disable are false....

this is the code that i add after ur code...

if(disable=true)
{
alert("Tahniah");
}
if((document.check.huruf4.disabled || document.check.huruf3.disabled || document.check.huruf2.disabled || document.check.huruf1.disabled) == false)
{
alert("Salah");
}
Sandeep Mewara 27-Mar-11 12:42pm    
Good to know your issue was resolved. I would appriciate closing the question now. This would help you and others in future.

About your follow up question, try:
if((!document.check.huruf4.disabled || !document.check.huruf3.disabled || !document.check.huruf2.disabled || !document.check.huruf1.disabled))
{
alert("One of the textbox is not disabled");
return false;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900