Friday, March 29, 2013

“If there is something that you can determine whether you will be entered into a text box” how to write a function?

Main issue merely by Candiecane: How to write an “if” function to validate whether or not something is entered into a textbox?

I cannot figure out the if function. I need to write the php code to echo something on a results page if someone has written something into a textbox or not. The name is “sender_email” and I need to figure out how to echo something when someone does not enter their email into the textbox. Please help!


This really is interesting facts about How to write an “if” function to validate whether or not something is entered into a textbox? that you may must have to resolve issues them selves. Perhaps it will aid in lots of ways… and generate yourself much better. Praying interesting facts about How to write an “if” function to validate whether or not something is entered into a textbox? tend to be an option at a later date.

Optimum solution:


Answer by Thomas B

It’s actually rather simple when you see the code. Take a look at this code.


<?php

if ("username" == "") {

echo "Please fill in your username";

}


Hope this helps

?>


Answer by elven_rangers

The most elegant way to solve this is through javascript.


Make a validation function triggered by the onsubmit event of the form (or simply don’t use a instead use a general button, add a custom javascript function for the onclick event and force the form to submit.


The code to validate an input in this form is:


function mySubmit() {

var strSenderEmail = document. getElementById(“sender_email”). value;

if(strSenderEmail. replace(/ /g,”") == “”) {

alert(“You must enter a sender email before sbumitting”);

} else {

myform. submit();

}


}


I assume you are doing some javascript that checks if your emails are properly formatted so I think you know where and how to use this piece of javascript.


the replace(/ /g,”") basically replaces the spaces in the input box with nothing so that if someone tries to bypas this by inputting just blank spaces, this will still trigger the alert (the replace doesn’t affect the actual value in the box, it is used just for the comparison).


Fully grasp good?

Leave the answer inside a comments!


Thumbs Up, Comment and Subscribe In continuing our iPhone 4 tips series, this time we cover email. Check out the video for all the details. Free Zollotech Ap…


Email Hack


Look with Email Hack


this email is: [ x ] blogable [ ] ask first [ ] private


My ever popular signature, now selectable through a pull down bar after setting some preferences in Apple Mail. Click, drag and cover your ass.


No lawyers were involved in composing this message.


“If there is something that you can determine whether you will be entered into a text box” how to write a function?

No comments:

Post a Comment

Blog Archive